intermediateTop 30 Scenario-Based Questions
Your application's database connection pool is exhausted. How do you diagnose and fix?
Diagnose: SELECT count(*), state, wait_event_type FROM pg_stat_activity GROUP BY state, wait_event_type — shows connection distribution. Check for idle-in-transaction connections (long-running transactions holding connections). Fix: 1) Connection pooler (PgBouncer in transaction mode): all app threads share a smaller pool of actual DB connections. pool_size=20 DB connections serve 500 app threads.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response