Try
↑ ↓ move↵ openesc close

Interview prep / Load shedding and backpressure

Mid · Load shedding and backpressure · System design interview question

Why might you limit the number of requests in flight instead of the request rate, and how does latency change what that limit means?

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

A strong answer

Rate says how many requests arrive per second. It says nothing about how long each one occupies the server. Requests in flight is what actually uses threads, memory and connections, and it is tied to rate and latency by Little's law: in flight equals arrival rate times time in the system.

Take a service with 20 workers and a 100 ms response time. It can sustain 20 / 0.1 = 200 requests a second. If a dependency slows and responses take 500 ms, the same 20 workers sustain only 40 a second. A rate limit of 200 a second would still admit 200, and 160 of them would pile up. A limit of 20 in flight stays correct in both cases: it admits what the workers can hold and refuses the rest, whatever the latency.

So a concurrency limit adapts by itself as the service slows. Requests above the limit are rejected at once, or held in a short queue, which gives you the bounded queue behaviour with little tuning.

The cost is that picking 20 still needs thought, since it depends on how much parallelism the machine really has. Some systems adjust the limit automatically, raising it while latency is steady and lowering it when latency climbs.

Sources

Learn it by running it

The load shedding and backpressure 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