A model serves requests per second, and you log (kilobyte, bytes) per prediction (inputs, output and model version). How much storage does this take per day, per days and per year ( days), why do we log predictions at all, and how can you cut the cost?
ML system design, Estimation
Level L2 Elementary. Length Short. Nature Mat Mathematical.
What's being asked
Whether you can convert QPS (queries per second) and record size into daily, monthly and yearly storage, and explain why logs exist and how to keep costs under control.
Key idea
Multiply requests per second by the number of seconds in a day () and the bytes per log entry. At and per record, logs grow by (gigabytes) per day, so teams use sampling and retention policies rather than keeping everything forever.
Steps
- Find requests per day: one day has seconds, so predictions per day.
- Compute storage per day using bytes and bytes:
- Compute storage for 30 days and 1 year (365 days), using (terabytes):
- Explain why teams log predictions: logs let you debug strange outputs, monitor input and score shifts, build fresh training datasets, and join predictions with delayed ground-truth labels (such as whether a click or fraud chargeback happened later).
- Describe how to cut storage cost: log a random sample (for example 1% or 10% of traffic), log compact feature IDs instead of raw payloads, compress old logs, and set a retention policy that deletes or archives logs after 30–90 days. Harder monitoring questions build on these logs to join delayed labels and track metrics such as PSI (population stability index).
Common mistakes
- Using (seconds in an hour) instead of (seconds in a day).
- Logging only the predicted score without the input features, request ID and model version, which makes it impossible to debug or join delayed labels later.
- Logging 100% of raw image or text payloads at high QPS without checking the monthly storage bill.
How long your answer should be
About 2 minutes; three clean numbers plus reasons and cost controls.
Read this
Previous in ML system design: Why does pure collaborative filtering fail on cold start, and how do you handle cold start for both new users and new items in a recommender system?
Next in ML system design: How would you design a spam filter for a small college email server that receives emails a day, of which about are spam? If your model achieves recall and a false-positive rate, how many spam emails are missed and how many legitimate emails are wrongly flagged per day?