Discussion about this post

User's avatar
Neural Foundry's avatar

Really clear explanation of why the naive per-request model collapses at scale. The pool-size tuning guidance is especially practical since most teams either start too small and hit wait time issues or overconfigure and waste connections during quiet periods. Your teaser about multiple instances is the key insight that often gets overlooked: with 10 app instances each running a 30-connection pool, you're suddenly at 300 database connections even if each instance is individually well-tuned. This is where tools like PgBouncer become essential, acting as a second-tier pooler that multiplexes across instances. One detail worth considering is that the optmal pool size often correlates more with database CPU cores than with application throughput since connection contention at the DB level becomes the real bottleneck.

Expand full comment
Nalongsak Luangkhot's avatar

I’m thinking one way we can avoid the database getting overwhelmed when we have, say, 10x instances, is to put a layer between the database and the 10x instances. Textbook microservice architecture of one microservice per database can be useful here. We can then make sure the number of instances of that microservice sitting right in front of the database is controlled and tuned to fit the performance need. Would love to hear more ideas!

Expand full comment
1 more comment...

No posts

Ready for more?