Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the use of the pool option in database.yml

Most widely used options in database.yml are of following :

adapter encoding database pool username password socket host port timeout 

I know the use of the most of the above but pool. So i want to know what is the use of the pool option in database.yml or there is any other parameter which we need to set for the application having very heavy traffic.

like image 907
Salil Avatar asked Sep 28 '12 07:09

Salil


People also ask

What is pool in database Yml?

For anyone else who is looking for an answer to this question, the basic idea seems to be that a database can only support so many simultaneous connections, so there needs to a way to limit the open connections. The pool attribute specifies the maximum number of connections that can be opened at a given time.

How does a database pool work?

The pool defines connection attributes such as the database name (URL), user name, and password. Now that it is connected to the database, the application can read, modify, and add data to the database. The applications access the database by making calls to the JDBC API.

What is connection pooling used for?

Using connection pools helps to both alleviate connection management overhead and decrease development tasks for data access. Each time an application attempts to access a backend store (such as a database), it requires resources to create, maintain, and release a connection to that datastore.

What is pool in MySQL?

The MySQL Thread Pool is a MySQL server plugin that extends the default connection-handling capabilities of the MySQL server to limit the number of concurrently executing statements/queries and transactions to ensure that each has sufficient CPU and memory resources to fulfill its task.


1 Answers

It sets the amount of possible connections per ruby process. So in case you are threading your rails app, or you use transactions excessively. The limits here depend on your setup. Consider this:

  • 50 ruby processes
  • each with 100 threads
  • a mysql with a setting of 1000 simultaneous connections

so it makes sense that every process can open at most 20 connections (50 * 20 == 1000) at a given time. So you would set the pool value to 20 or less.

like image 167
moritz Avatar answered Sep 17 '22 23:09

moritz