All jobs / Backend developer / Performance
Backend developer interview question · 1–3 years
The interviewer asks: “The API is idle but requests hang on 'opening a connection.' What's going on?” Strongest answer?
The strongest answer
The pool is exhausted — every connection is checked out, often by slow queries or a leak (missing dispose). I check pool metrics, active queries, and that every request releases the connection.
Why it works
Exactly. Hanging on the pool is a symptom: held connections or too much concurrency into a small pool. Fix the leak and the slow query; then size the pool to the database, not to hope.
What a good answer covers
- Hangs here often mean a starved pool.
- Find leaks and slow queries first.
- Size the pool to the database, not to infinity.
- Don't turn pooling off.
Answers that fall short
- Close, but not the strongest: The database is down; I restart the API.
Restarting clears the leak until the next traffic spike. Find who isn't returning connections. - Weak: I raise Max Pool Size to 1000 so we never wait.
A huge pool DDoSes Postgres/SQL Server. The database has a max_connections too. Size both. - Red flag: I disable pooling so each request gets a fresh connection — simpler.
No pooling means a TCP+auth handshake per request. You'll melt the DB faster, not simpler.
Who gets asked this
More Performance questions
- The interviewer asks: “The API returns 429. What should a client do?” Strongest answer?
- The interviewer asks: “You add Cache-Control to a JSON API. What do you watch for?” Strongest answer?
- The interviewer asks: “Why is OFFSET 100000 slow even with a LIMIT 20?” Strongest answer?
- The interviewer asks: “Where do you enforce rate limits?” Strongest answer?
- The interviewer asks: “This query is slow in production but fine on your laptop. What do you do first?”…
- An endpoint takes 1.5 seconds at p95. The container’s CPU sits at 8% and the CPU profiler shows almost…
- The interviewer asks: “The cache expires and 2,000 requests hit the database at once. How do you prevent…
- Under load, someone raises the connection pool from 20 to 200 per instance. Throughput drops and p95 gets…