Connection pool sizes are probably the biggest footgun out there in every Rails application.

Use a single ENV variable to control:
1. Database pool size
2. Puma thread count
3. Sidekiq thread count

RAILS_MAX_THREADS is good for this. If any one of these is out of sync, can cause a BIG issue. Just set it once in one place.

2
Share
Share on Mastodon
Share on Twitter
Share on Facebook
Share on Linkedin
Jonathan del Strother

@nateberkopec you maybe need the pool size to be a multiple of thread count though, right? eg for dealing with async queries.
I’m not really sure what the downside is to setting the pool size to say, 10x the thread count, other than maybe making it more difficult to discover a connection leak

0
3mo
Tekin Süleyman

@nateberkopec yes, except sometimes Puma threads spawn additional threads to complete a request, resulting in connection contention: tekin.co.uk/2023/07/active-rec.

0
3mo
Replies