Interview replay

Full round replay — connection pool sizing

10 minintermediate115 yrs

Timed verbal replay with pass/fail criteria per follow-up.

How to run this

Answer out loud, timed. Do not read the entry first. Then compare against "The Answer" and "Interviewer's Next Move" and mark yourself.

The opener

How do you size a database connection pool?

Budget: 45 seconds. Going long here is itself a fail signal.

Follow-ups

  1. 1. “Our pool is 100. Is that right?

    Testing: Whether they ask the right question back.

    Scoring

    Pass: Almost certainly too big. It implies either enormous throughput or a long hold time, and the second is far more common. What is the hold time?

    Fail: Says it depends, or accepts it.

  2. 2. “Why would a smaller pool be faster?

    Testing: The counterintuitive core.

    Scoring

    Pass: A pool is a concurrency limit, not capacity. Past what the database can genuinely run at once, more connections add lock contention, cache churn and context switching — and move the queue from the application, where it is visible and can shed load, into the database, where it is not.

    Fail: Thinks more connections always means more throughput.

  3. 3. “What is the single most important number?

    Testing: Hold time, and why it is missed.

    Scoring

    Pass: Hold time. The same pool of twenty serves ten thousand requests a second at a 2ms hold and a hundred at 200ms. Almost nobody measures it, because it covers everything between getConnection and close rather than just query execution.

    Fail: Says pool size, or throughput.

  4. 4. “What happens when the pool is exhausted?

    Testing: Where the failure appears.

    Scoring

    Pass: Requests fail at acquisition with a pool timeout, before touching the database — in HikariCP, a SQLTransientConnectionException saying the request timed out. The database may be entirely idle while it happens.

    Fail: Expects a database error or a slow query.

  5. 5. “Pool exhausted, database idle. Where do you look?

    Testing: The diagnosis.

    Scoring

    Pass: At my own code. Something is holding connections rather than something being slow — usually a remote call inside a transaction, or a close() that sits after code which can throw. HikariCP's leak-detection-threshold logs a stack trace naming the holder.

    Fail: Investigates the database.

  6. 6. “Would you raise the acquisition timeout?

    Testing: A tempting wrong answer.

    Scoring

    Pass: No — that queues instead of shedding load, so requests pile up until callers give up first and the queued work is wasted. A short timeout refuses some requests immediately, which beats making all of them slow.

    Fail: Raises it to stop the errors.

  7. 7. “You have twelve instances. What is your pool size?

    Testing: Aggregate thinking.

    Scoring

    Pass: Smaller than for one, and the number that matters is the total: instances times pool, plus batch workers, admin tools and monitoring, against max_connections. Autoscaling silently multiplies the first term.

    Fail: Gives a per-instance number with no total.

  8. 8. “When would you put PgBouncer in front?

    Testing: Knowing the next tier and its cost.

    Scoring

    Pass: Past a few hundred connections, or with elastic instance counts. In transaction mode it multiplexes many client connections onto few server ones, and session-level state does not survive — prepared statements, temporary tables, advisory locks, session SET.

    Fail: Proposes it with no caveats, or has not heard of it.

  9. 9. “Do virtual threads change the sizing?

    Testing: Precision about what changed.

    Scoring

    Pass: Not the arithmetic. A platform thread pool used to cap database concurrency as a side effect; virtual threads remove that, so ten thousand tasks can reach for a pool of ten. The pool becomes the only backpressure, which makes the acquisition timeout a load-shedding decision.

    Fail: Says virtual threads fix pool contention.

  10. 10. “One setting on an unfamiliar service?

    Testing: Practical judgement.

    Scoring

    Pass: leak-detection-threshold. It costs nothing and answers the question the whole topic turns on — what is holding connections — with a stack trace instead of a theory.

    Fail: Changes the pool size before measuring anything.

Score yourself

10/10 — you can size a pool and defend it, and diagnose one at 3am 7-9 — solid; the timeout and aggregate answers are where points go 4-6 — you know the formula but not the diagnosis; redo the Production tier 0-3 — exhaust a pool yourself and read the exception

← Back to How do you size a database connection pool?