Puma thread config when using Jemalloc

Puma can be configured with min and max threads. Last time I looked into it a few years ago, it was typical to simply fix the min and max to the same number. I think a main reason to do this was to avoid memory bloat problems caused by MRI.

I think this problem is not an issue or maybe significantly less when using Jemalloc (which I am). So I want to try setting min threads to 0, so I can monitor how many threads puma actually needs, and reduce the number of db connections used.

Anyone have experiences or knowledge to share along these lines? Thanks!


I have very little concrete knowledge, but I’ve done plenty of trial and error. My website had memory usage spikes that I suspect has to do with Refinery CMS that got exacerbated by a bad image caching setup, and with MRI we had out of memory crashes at least once a week (more often on heavy traffic). Jemalloc (I use the Fullstaq Ruby binary packages on Centos 8) fixed all of this. I use 5 threads as max now, but that’s mostly just out of caution, so please post what you find!