Interview Databases & Caching

What is connection exhaustion, and how do you prevent it?

Databases & Caching · Intermediate level

Answer

Connection pooling reuses a bounded set of database connections and prevents unbounded clients from exhausting the database. RDS Proxy is a managed pooling proxy that helps with bursty traffic, Lambda concurrency, failover recovery, and credential rotation.

Technical explanation

Each DB connection consumes memory and CPU; in Kubernetes total connections equal pod count times pool size.

RDS Proxy multiplexes when session state allows it, but pinned sessions reduce benefits.

Prevention includes pool caps, backoff with jitter, timeouts, RDS Proxy/PgBouncer, and avoiding unbounded concurrency.

Hands-on example

Pool sizing example:

DB safe app budget = 850 connections

App pods = 50

Max pool per pod = floor(850/50) = 17

Choose 10 to 15 and load test.

PostgreSQL check:

SELECT usename, application_name, state, count(*) FROM pg_stat_activity GROUP BY 1,2,3 ORDER BY count(*) DESC;

Preparing for an interview?

Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.

More Databases & Caching interview questions

← All Databases & Caching questions