No history yet

System Design Framework

The ML System Design Framework

Any scalable machine learning system relies on a repeatable design process. This isn't about reinventing the wheel for every new product feature. It's about applying a consistent framework to translate ambiguous goals into robust, production-ready systems. We'll refresh the core tenets of the widely adopted 7-step process, focusing on the points where even experienced engineers stumble: translating business needs, defining non-functional requirements, and building resilient feedback loops.

From Business Goal to ML Metric

The first step is the most critical: converting a vague business objective into a concrete, optimizable machine learning metric. A request to 'increase user engagement' is not an ML problem. It's a business goal. The engineering task is to decompose this into proxy metrics the model can actually influence.

For a recommendation system, 'engagement' might translate to a weighted combination of Click-Through Rate (CTR) and dwell time. This forces a clear definition of success. A high CTR with low dwell time could indicate clickbait, while high dwell time on its own might not drive discovery. The key is to create a loss function that balances these competing factors and aligns with the true business intent. This mapping is an iterative process, refined through A/B testing and analysis.

Defining System Constraints

With a clear objective, the next step is to define the non-functional requirements. These constraints shape the entire architecture. For real-time systems like a newsfeed ranker or a typeahead search, latency is paramount. A typical target is a P99 latency under 100-200 milliseconds. Anything slower feels sluggish and degrades the user experience.

Throughput requirements dictate the system's capacity. Are we serving a few thousand requests per day or billions? This determines decisions around horizontal scaling, load balancing, and infrastructure choices. Finally, data freshness defines how quickly the system must react to new information. A fraud detection system needs near-real-time feature updates, while a weekly analytics model has much looser requirements.

This architecture separates concerns effectively. The offline layer is for heavy-duty model training, where multi-hour jobs process terabytes of historical data. The trained models are then pushed to a model registry.

The online serving layer is built for speed. It receives a user request, fetches pre-computed and real-time features from a feature store, and serves a prediction with minimal latency. The nearline, or streaming, layer acts as the bridge, processing raw event data into fresh features for the online system to use.

Closing the Loop

The most common point of failure in production ML systems is an inadequate feedback and monitoring strategy. Models don't fail loudly; they degrade silently. This occurs as the statistical properties of live data drift away from the training data's properties.

A robust system is a closed-loop system. Every prediction, and the user interaction that follows, must be logged. This data is the lifeblood for monitoring, retraining, and debugging. Monitoring shouldn't just track accuracy. It must watch for drifts in the distributions of input features and model outputs. When these metrics breach a set threshold, it should trigger an alert or an automated retraining pipeline. Without this, a high-performing model can become worse than useless over time.

StepFocusKey Question
1. Problem DefinitionBusiness to MLWhat user behavior are we trying to influence?
2. Data EngineeringCollection & PrepDo we have the necessary data, and is it clean?
3. Model DevelopmentTraining & SelectionWhat is the simplest model that meets the performance bar?
4. EvaluationOffline & OnlineHow does the model perform on held-out data and in live A/B tests?
5. ServingArchitectureHow do we serve predictions within our latency/throughput budget?
6. MonitoringHealth & DriftHow do we know the model is still working correctly in production?
7. IterationFeedback LoopHow do we use new data to continuously improve the system?

With this framework in mind, you can systematically approach any ML design problem. Now, let's test your understanding of these core concepts.

Quiz Questions 1/5

A product manager asks you to build an ML system to "increase user engagement" for a video platform. What is the best first step?

Quiz Questions 2/5

In the context of a real-time ML system like a newsfeed ranker, what does a P99 latency of 150ms signify?

This framework isn't a rigid checklist but a mental model. It ensures you address the critical engineering challenges that separate a proof-of-concept notebook from a scalable, reliable machine learning system that delivers real business value.