ML Systems Lab Open interactive version →
Advanced 25 min read real-time MLlatencystreamingcachingserving

Real-Time ML

Streaming features, latency SLAs, caching, async fan-out, fallbacks

A fraud model that answers in 500ms is useless — the transaction clears in 200ms or the user gives up. A recommender that takes 2 seconds has already lost the session. This is the one hard constraint batch ML never faces: the prediction must arrive *before the user's patience runs out.*


Everything that makes the model better makes it slower. Every extra feature buys accuracy and costs latency; every extra layer, the same. So real-time design isn't vague tradeoffs — it's *numbers*: not "this adds latency" but "this adds 15ms, the SLA is 50ms, so 35ms is left for everything else." You budget milliseconds like money, because you can't spend what you don't have.


Async fan-out is non-negotiable. Issue all feature-store requests in parallel and wait for the *max*, not the *sum*: four 8ms features in parallel cost 8ms, in serial 32ms. Pair each with a timeout that returns a default rather than blocking past the SLA. Precompute what you can — stream user aggregates into a cache so serving is a lookup plus a light adjustment, not a heavy recompute.


Define the fallback before the incident, not during it. Every real-time system needs a documented answer to "what happens when the model endpoint is slow or down": popularity response, rule-based score, or last cached prediction, behind a circuit breaker that trips to the fallback when error rate crosses a threshold. The organizational catch: model-builders optimize accuracy, serving-builders optimize latency, and unless the budget is explicit and shared, each optimizes its own half and the system misses the SLA that only exists when you add both.

Key points

Takeaway

Real-time ML is latency budgeting in milliseconds: accuracy and latency trade off continuously, async fan-out converts feature-fetch cost from a sum to a max, and a predefined fallback behind a circuit breaker is what keeps the system answering when the model can't — with the budget made explicit so accuracy and serving teams don't each optimize half.

Recap

Check your understanding

Q1. Select the two correct parts of the fix when a fraud model has 150ms P99 against a 50ms SLA.

Q2. Four feature sources each take 8ms. Your service fetches them one after another and blames the model for a 40ms+ latency. What's the actual problem?

Q3. Why is a documented fallback + circuit breaker considered part of the *design*, not an ops afterthought?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →