KatInterview

Keeping Latency SLOs Alive During Traffic Spikes

System DesignModel answer
HardModel answerSystem Designload-sheddingrate-limitingadmission-control

Last updated

Design a layered overload protection system that sustains goodput and p99 latency targets when request volume suddenly surges beyond provisioned capacity.

The Scenario

Your team runs a high-traffic API — think a content feed or recommendation engine — serving roughly 500,000 requests per second at steady state. Twice a year, a live event or a mass push notification drives traffic to 3× that in under 10 seconds. Autoscaling takes 2–5 minutes to kick in. During that gap, without protection, latency collapses and the service becomes effectively unavailable for everyone.

Your job is to design a system that stays useful under that spike: not zero errors, but a graceful degradation where high-value requests still succeed within SLO.

What You're Expected to Cover

Requirements and scale State your assumptions. What are the SLOs (latency, availability)? What are the traffic classes? What is out of scope (e.g., DDoS scrubbing)?

Request contract and metadata How do priority, deadlines, and tenant identity flow through the stack? How do clients and downstream systems know a request was shed versus failed?

Architecture overview Sketch the layers — edge/load balancer, app-level admission, priority queues, worker pool, dependency calls — and explain the principle behind shedding decisions at each layer.

Rate limiting mechanics Explain token buckets: the parameters, what they protect against, and where they fall short.

Adaptive admission control Why is a static RPS cap insufficient? How does an adaptive concurrency limit work, and how does it differ from a token bucket?

Priority queues and deadline propagation How do you bound queues from the latency budget? What is deadline-aware dequeuing? When does LIFO beat FIFO under sustained overload?

Load shedding strategies Compare at least four strategies (drop-new, drop-tail, random/probabilistic, deadline-aware): mechanics, trade-offs, and where in the stack each belongs.

Circuit breakers and backpressure How do circuit breakers prevent a slow dependency from cascading? What backpressure signals go to upstream callers and queues?

Metrics and validation What do you instrument to know the system is working? How do you distinguish a spike that was handled well from one that was not?

Hints

Hint 1

Start by deriving a concrete queue depth limit from the latency budget using Little's Law — this single number drives most of the design decisions that follow.

Hint 2

Token buckets catch expected abuse from known clients, but they cannot detect that your own server has slowed down due to GC or a noisy neighbor. A separate mechanism owns that case.

Hint 3

When comparing shedding strategies, think about what information is available at each layer: the load balancer knows IP, tenant, and route; the app knows priority, cost, and deadline. Match strategy to information.