Skip to main content

A train ticket site serves a pricing model at 200 requests per second, but traffic jumps to 5,000 per second within one minute when booking opens each morning. Design serving that keeps p99 latency under 150 milliseconds.

System design · Pro 1

Short answer

Clarify the traffic shape and what a slow or failed response costs. Then: stateless replicas behind a load balancer, autoscaling on requests in flight instead of CPU, scheduled scale-up before the known spike, warm instances with the model already loaded, request batching, load shedding with a cheap fallback, and load tests that replay the spike.

Deeper answer

First clarify the pattern. This spike is predictable, daily and very steep. Reactive autoscaling alone is too slow, because a new replica needs time to start, pull the image and load the model, often longer than the one minute ramp.

Design: stateless model servers behind a load balancer, each with the model loaded at start and a readiness check that passes only after a warm-up request. Autoscale on a signal that follows load closely, such as concurrent requests or queue length per replica. CPU usage reacts late. Add scheduled scaling that raises the minimum replica count some minutes before booking opens, and keep headroom over the expected peak. Inside each server, small dynamic batches raise throughput. Set a timeout and a concurrency limit, and shed extra load to a cheap fallback such as a cached price or a simpler model.

Trade-offs: capacity that waits idle costs money, and cold starts cost latency. Test with a load test that replays the real ramp, and measure p99 and error rate, not the average. At scale, the first failures are cold starts, slow feature lookups downstream, and retry storms from clients.

What a strong answer covers

Answer it out loud in the mock interview about 2.5 min

Follow-ups to expect

Common mistakes

Learn it

Serving a model

Practice System design questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.