The interview problem

Practice prompt

Thousands of application instances each open a large connection pool, overwhelming a database. Design an admission layer and explain why adding connections can reduce throughput.

Original practice, not a reported company interview. All scenarios and worked numbers are illustrative. Interview date: not applicable. Sources retrieved September 30, 2026.

1. Scope and assumptions

Assume short transactional requests with a bounded database concurrency target. Pooling session state requires compatibility analysis; transaction pooling is not transparent for every application feature.

2. Worked approach

authenticated request
  → bounded queue
  → compatible pooled connection
  → transaction
  → release

Place a bounded pool between clients and the database, with per-tenant queue limits, acquisition deadlines and cancellation propagation. Estimate demand from measured transaction service time and protect administrative access separately. Return explicit overload rather than allowing unbounded waiters to exhaust application memory.

Define whether connections are held per session or transaction. Audit session variables, temporary objects, prepared-statement behavior and connection-specific locks against the selected pooler's supported configuration. Reset reusable state safely; a later tenant must not inherit a previous tenant's settings. Observe queue wait independently from query execution time.

3. Calculate the example

If throughput is 2,000 transactions/s and mean time occupying a database connection is 40 ms, Little's-law occupancy is about 80 connections under steady-state assumptions. This is not a safe maximum or a p99 guarantee. Configuring 1,000 application instances with 50 connections each offers 50,000 connections, far beyond that average need. A 500-request queue draining at 2,000/s adds about 250 ms in a simplified no-new-arrival calculation.

4. Failure cases and trade-offs

Leaked transactions hold connections indefinitely. A canceled HTTP request may leave its query executing. Pool acquisition timeouts followed by aggressive retries amplify load. Session-state leakage is a correctness problem even if throughput improves.

A smaller pool bounds database contention but increases queueing under bursts. A larger pool can reduce acquisition waits until database service time rises from contention. Tune with load tests and actual resource saturation, not a universal connections-per-core rule.

5. Validate the result

Exercise long transactions, canceled clients, failover and stateful database features. Measure useful throughput, queue age, lock waits and tail latency. Confirm rejected requests do not immediately re-enter through uncontrolled retry loops.

6. Interview follow-ups and self-review

How do migration jobs obtain capacity? What if one tenant holds long transactions?

Reward concurrency budgeting, pooling compatibility, cancellation semantics and qualified Little's-law arithmetic.

Sources and related practice

Technical reference: www.pgbouncer.org — Official pooling modes and compatibility reference; admission design is original.

Exact publication/update date not established in this review. Retrieved September 30, 2026. This reference supports the named technical concept; the proposed workflow and examples are original, not a documented vendor implementation or interview report.

Continue with Limit concurrent work across service instances; Investigate an AI customer’s capacity and cost problem.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.