Try
↑ ↓ move↵ openesc close

Interview prep / Connections and head-of-line blocking

Junior · Connections and head-of-line blocking · System design interview question

Why do clients keep a pool of connections, and what is the risk of getting its size wrong?

Sketch your own answer first, then compare it with the one below.

A strong answer

A pool lets requests reuse open connections, so most requests skip the handshake. It also bounds how many connections a client holds.

Too small and requests wait for a free connection, which shows up as queueing and high tail latency. Too large and it wastes memory and file descriptors on both ends, and the sum across many clients can overload a server or a database behind it.

Size it from the request rate and how long a connection is busy, and add headroom for bursts.

Sources

Learn it by running it

The connections and head-of-line blocking lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms