If my Rails application has the database pool size set to 5 (the default) in my database.yml file, and I'm running using Phusion Passenger, does that mean that there may be up to 5 database connections for each process that Passenger spawns, or is it 5 total across all processes?
You reuse a prior database connection, in a new context to avoid the cost of setting up a new database connection for each request. The primary reason to avoid using database connections is that you're application's approach to solving problems isn't structured to accommodate a database connection pool.
What is database connection pooling? Database connection pooling is a way to reduce the cost of opening and closing connections by maintaining a “pool” of open connections that can be passed from database operation to database operation as needed.
Connection pooling means that connections are reused rather than created each time a connection is requested. To facilitate connection reuse, a memory cache of database connections, called a connection pool, is maintained by a connection pooling module as a layer on top of any standard JDBC driver product.
Connection pooling often improves application performance, concurrency and scalability.
The pool size applies to one ruby process. Some ruby interpreters can use threading to handle multiple requests, like jRuby. The pool size applies for that one process and all threads.
Passenger does not use threading, but instead creates new ruby processes.
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