对于数据库中的池大小,我应该考虑什么?

时间:2021-05-05 07:11:10

I've been having some thoughts on setting the appropriate pool size (in database.yml).

我一直在考虑设置合适的池大小(在database.yml中)。

I saw a similar question at what is the use of the pool option in database.yml but needed to go further to understand this more.

在数据库中使用池选项时,我看到了类似的问题。但是要进一步了解这个。

Here is my setup. I have instances running Unicorn with 5 worker process'. I also have Sidekiq instances with concurrency set to 5 (I am asumming thats 5 concurrent threads).

这是我的设置。我有实例运行独角兽与5工人进程'。我还有Sidekiq实例,并发性设置为5(我正在对5个并发线程进行分析)。

What should I consider for my pool size? What are other factors should I take into consideration?

我应该考虑我的泳池大小?我还应该考虑哪些因素?

This is my understanding so far (as quoted from an engineer I was speaking to earlier):

这是我到目前为止的理解(引用我之前与一位工程师交谈过的一句话):

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

假设你把它设为默认值5。它只是意味着,在“单个进程”中,池大小为5。池是每个进程。它不是系统范围内的,所以值为5并不意味着您被限制为5个进程,它只是意味着每个进程都有自己的池,大小为5。

In summary, each instance has a db pool size of 5. This also means the db pool size setting is not app wide, but per process/instance. Which also means, since Sidekiq and Unicorn will run in its own instance. It will have its own db pool size of 5. Is this assumption correct?

总之,每个实例的db池大小为5。这也意味着db池大小设置不是应用程序范围内的,而是每个进程/实例。这也意味着,因为Sidekiq和Unicorn将运行在自己的实例中。它将拥有自己的db池大小为5。这个假设是正确的吗?

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

此时,我可以假设默认池大小为5通常是安全的。你的想法呢?

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

PS.如果您可以共享您的AWS RDS实例的池大小。那将是感激。

1 个解决方案

#1


2  

Your pool size in database.yml should be not less then max number of sidekiq/unicorn processes (not sum). Example, if unicorn running with 5 processes and sidekiq starting with 15 concurrency, you should set 15 pool size. Or, if unicorn with 7 and sidekiq with 5, you need 7 connections in database.yml.

数据库中的池大小。yml不应小于边基克/独角兽过程的最大数目(不应小于和)。例如,如果独角兽以5个进程运行,而sidekiq以15个并发开始,您应该设置15个池大小。或者,如果独角兽有7个,而sidekiq有5个,你需要数据库中的7个连接。

#1


2  

Your pool size in database.yml should be not less then max number of sidekiq/unicorn processes (not sum). Example, if unicorn running with 5 processes and sidekiq starting with 15 concurrency, you should set 15 pool size. Or, if unicorn with 7 and sidekiq with 5, you need 7 connections in database.yml.

数据库中的池大小。yml不应小于边基克/独角兽过程的最大数目(不应小于和)。例如,如果独角兽以5个进程运行,而sidekiq以15个并发开始,您应该设置15个池大小。或者,如果独角兽有7个,而sidekiq有5个,你需要数据库中的7个连接。