What should I consider for pool size in database.yml?

I had some thoughts on setting the appropriate pool size (in database.yml).

I saw a similar question in what is the use of the pool option in the database.yml file , but for this you need to understand even more.

Here is my setup. I have Unicorn instances with 5 workflows. I also have Sidekiq instances with concurrency set to 5 (I'm asumming thats 5 simultaneous threads).

What should I consider for pool size? What other factors should be considered?

This is my understanding so far (as quoted by the engineer I spoke with before):

Suppose you leave it at default 5. This simply means that inside β€œa is a single process”, the pool size is 5. The pool per process. It is not system-wide, so a value of 5 does not mean that you are limited to 5 processes, it means that each process has its own pool of size 5.

In general , each instance has a db pool size of 5. This also means that the db pool size is not wide, but for each process / instance. It also means that Sidekiq and Unicorn will work in their own example. It will have its own db 5 pool size. Is this an assumption correct?

At this point, I can assume that the default pool size of 5 is generally safe. Your thoughts?

PS. If you can share your pool size for your AWS RDS instances. That would be appreciated.

+8
database ruby-on-rails postgresql ruby-on-rails-4
source share
1 answer

The size of your pool in database.yml should be no less than the maximum number of sidekiq / unicorn processes (and not the sum). For example, if a unicorn is running 5 processes and sidekiq starting at 15 concurrency, you must set 15 pools. Or, if the unicorn is with 7 and sidekiq with 5, you need 7 connections in database.yml.

+2
source share

All Articles