Do you really need a db connection pool for unicorn rails?

I cannot find any document describing the effect of pooling a database for unicorn .

A unicorn deploys several workflows. I configured prefork and is not critical so as not to use communication between workers, so I reset the db connections after fork.

In my rails application there are 8 workers per server, and the pool size in database.yml is 5, then I saw 45 connections to mysql.

Each worker is single-threaded, which processes 1 request at a time. SQL queries should be blocked. Does the other 4 connections seem to be useless? Can I set the pool size to 1 for better performance?

+7
source share
1 answer

Since each worker can only serve one request at a time, each worker can use only one connection at a time, and nothing is obtained from getting more connections. If you set the pool size to 1, each Unicorn employee must open one connection. Most likely, you will not get a noticeable increase in performance, but you will save resources by having fewer open connections.

+7
source

All Articles