Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What units is timeout in Rails database.yml?

In database.yml, is the timeout in seconds or milliseconds? And what specifically is it, the timeout for the entire database connection including wait time for a connection or something else?

like image 244
Some Guy Avatar asked Mar 21 '15 05:03

Some Guy


People also ask

What is in database yml rails?

The database. yml is the file where you set up all the information to connect to the database. It differs depending on the kind of DB you use. You can find more information about this in the Rails Guide or any tutorial explaining how to setup a rails project.

Where is database yml located?

The main databases. yml configuration file for a project can be found in the config/ directory. Most of the time, all applications of a project share the same database. That's why the main database configuration file is in the project config/ directory.

Is Ruby on Rails a database?

Ruby on Rails is an open source web framework written in Ruby. Rails is database agnostic, meaning it can be used with a variety of different databases. By default it assumes that MySQL is being used, but it's quite easy to use with Postgres instead.


2 Answers

the timeout is in milliseconds. This is the entire time which rails app wait for database response. Good practice is to add reconnect option in this file then the application will try reconnecting to the server before giving up in case of a lost connection.

like image 82
Radek Avatar answered Oct 02 '22 04:10

Radek


Number of seconds to block and wait for a connection before giving up and raising a timeout error (default 5 seconds).

wait_timeout: 900 # 15 minutes.
timeout: 5000 # 5 seconds.

MYSQL Docs say :

 1. wait_timeout : The number of seconds the server waits for activity on a
   noninteractive connection before closing it. The default value is 28800.

 2. connect_timeout : The number of seconds that the mysqld server waits for
   a connect packet before responding with Bad handshake. The default value is 10 seconds.

connect_timeout mysql is mapped to timeout defined in data_base.yml rails which is set to 5 seconds default.

like image 37
Satishakumar Awati Avatar answered Oct 02 '22 03:10

Satishakumar Awati