Determining the optimal DB pool size for Rails 4 on Puma

I am having problems with errors ActiveRecord::ConnectionTimeoutErrorin my application recently. This is a Rails 4 application deployed to Heroku on Puma. When I start heroku pg:info, I see that only 5/20 connections are active when I encounter an error ActiveRecord::ConnectionTimeoutError. I ended up increasing my variable MAX_THREADSand MIN_THREADSenv from 2 to 5 after reading this post in the Heroku forum , which is why the problem has disappeared for now, but this solution seems to apply black magic to the problem and hope that it goes away.

What I would like to know is how I can correctly determine how large my connection pool should be. Now I have one web worker and two additional resqueworkers.

My application is currently handling a lot of S3 image downloads, which I think might cause a problem. This is what I want to talk to the employee about resqueto free the web employee. I noticed that the boot process accelerated when I increased the pool size, however, I am worried that simply increasing the pool size is not a scalable long-term solution.

+4
source share

Source: https://habr.com/ru/post/1612441/


All Articles