Node.js · Senior · Question 71 of 75
You scale to 40 instances, each with a pool of 20 connections, and PostgreSQL starts refusing connections. What helps?
- 1Increase every pool to 100 connections
- 2Open a new connection for each query instead of pooling
- ✓Correct answer: Reduce pool sizes and put a connection pooler such as PgBouncer between the app and the database
Explanation
Total connections = instances × pool size, and each PostgreSQL connection is a process with its own memory. A pooler multiplexes many client connections onto few server ones.