I'm wondering if database pools should always be set to 25 conns.

Puma/Sidekiq is not the only source of concurrency. load_async, Parallel, Thread.new, fibers, etc. So RMT + 5 doesn't make sense.

25 is low enough to catch leaks, high enough to allow concurrency

3
Share
Share on Mastodon
Share on Twitter
Share on Facebook
Share on Linkedin
nate berkopec

sorry, RMT = RAILS_MAX_THREADS or whatever you use to set your puma/sidekiq concurrency

0
16d
nate berkopec

The costs of setting pools too low is obvious - high latency caused by concurrent threads blocking on checking out a connection.

Pool "too high" cost is you don't catch leaks. But leaks have been far less of an issue in recent years, and there's probably better ways to detect.

0
16d
Irving Reid

@nateberkopec open connections may have a cost on the DB server - not sure about Postgres but MySQL definitely has a significant memory load per connection.

0
16d
Replies