Reputation: 522
Is there any formula to discover the number of workers and threads in a Rails application using puma ? Worker would be the number of cores ? How about threads ?? I've tried to search in similar topics, but it was not clear to me...
Upvotes: 6
Views: 6968
Reputation: 8551
Number of Worker * Number of threads inside the worker = Database Connection pool size
For example, if you are using 2.5 GB RAM's plan and you want to make use of it up around 2 GB.
1 worker * 8 threads = 8(DB pool size)
Upvotes: 1
Reputation: 381
If you are using Heroku you can set your number of workers using puma according to your web dyno size.
For some applications two Puma workers will cause you to use more RAM than a standard-1x dyno can provide
Upvotes: 0
Reputation: 3430
Even if your not on Heroku they have good doc about Puma. Like this one: link
This answer helped me when I was asking myself the same question.
Basically I set the number of workers matching the number of cores and the number of threads according to the ram amount. But I'm not doing this with a rocket science formula (maybe I should), it's more like a try and adjustment process.
As a bonus reading I would suggest this article about how to scale a rails app to 1000 req/sec, it gives interesting suggestions: link
Upvotes: 5