Skip to content
Preptima

Top 4 Connection pool Interview Questions

Browse 4 real-world technical and behavioral interview questions about Connection pool. Review scenarios, edge cases, and architectural best practices.

Implement a thread-safe pool of N connections with acquire, release and a timeout.

A thread-safe connection pool pairs a Semaphore of N permits, which bounds how many connections exist and gives acquire its timeout, with a queue of idle connections. Acquire returns a lease that releases exactly once from a finally block, and a broken connection is discarded without losing its permit.

hardcoding

A method with REQUIRES_NEW was meant to save an audit row even when the main transaction fails. When does it work, and when does it deadlock?

REQUIRES_NEW suspends the caller's transaction and commits the audit on a second connection, so the row survives a later rollback if the call goes through the Spring proxy. It hangs when the audit touches rows the suspended transaction has locked, or when every thread holds one pooled connection and waits for another.

hardconcept

Your p99 latency jumped tenfold after a deploy while p50 is unchanged. Diagnose it out loud.

A flat p50 rules out a uniform slowdown, so the tail belongs either to a subset of requests or to a queueing effect. Partition the latency histogram by instance, endpoint and tenant before naming a cause, then confirm with traces, GC logs and pool-wait metrics.

hardscenario

Your database fails over and is accepting connections again within thirty seconds, but your service returns errors for ten minutes. Where is that time going?

The database recovered; your clients did not. Sockets to the old primary hang rather than fail, a cached DNS answer keeps pointing at it, the promoted node refuses writes while it finishes, and then the whole fleet reconnects at once. Attribute the ten minutes to those stages before tuning anything.

hardscenario