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.
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.
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.
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.
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.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With