ML System Design and Lifecycle
Problem Framing
Start with the 'Why'
In a machine learning system design interview, the first questions aren't about code or algorithms. They're about clarity. The interviewer gives you a vague business goal, like “improve our video recommendations,” and waits to see what you do.
The biggest mistake is to jump straight to a solution. Instead, the first step is always to frame the problem. Your goal is to translate a business need into a concrete machine learning task. This means defining what you're trying to predict, what data you'll use, and how you'll measure success before you even think about a model.
Model selection in an ML system design interview is less about naming the most advanced algorithm and more about justifying why a particular approach makes sense given the problem, data, and constraints.
From Business Goals to ML Objectives
A business goal is often broad, like “reduce customer churn.” An ML objective is specific and measurable. To bridge this gap, you need to ask clarifying questions. Who are the users? What is the desired outcome for them? How does this benefit the business?
For a video recommendation system, is the goal to maximize clicks? Or is it to increase total watch time? These are different objectives that lead to different systems. Maximizing clicks might promote clickbait, while maximizing watch time encourages longer, more engaging content. The business goal (“increase engagement”) must be translated into a precise ML metric.
Once the objective is clear, you define your inputs and outputs. The inputs, or features (), are the pieces of information the model will use to make a prediction. The output () is the target you want to predict. This is your .
For our video recommender, the features () could include the user’s watch history, the video’s genre, and the time of day. The label () would be a binary value: 1 if the user watched for more than 60 seconds, and 0 if they didn't. This formulation turns the vague business problem into a well-defined binary classification task.
Constraints and Trade-offs
No system is built in a vacuum. You must identify the constraints. How quickly does the prediction need to be made? A model recommending the next video in a playlist needs an almost instantaneous response, imposing a strict requirement. A model that generates a weekly analytics report has much looser constraints.
Other constraints include computational cost, data availability, and interpretability. Can the company afford to run a massive neural network for this task? Is there enough labeled data to train it? Do we need to explain why the model made a specific prediction, for example, in a loan application system?
A crucial decision is whether the system will use batch or online inference. This determines how and when predictions are made.
| Feature | Batch Inference | Online (Real-Time) Inference |
|---|---|---|
| When It's Used | When immediate predictions are not needed. | For interactive, user-facing applications. |
| How It Works | Predictions are generated for many inputs at once, on a schedule (e.g., hourly, daily). | Predictions are generated for a single input as soon as it's received. |
| Example | Calculating daily personalized product recommendations for all users overnight. | Detecting a fraudulent transaction the moment it occurs. |
| Data Freshness | Predictions are based on older data. | Predictions use the most up-to-the-minute data. |
| Cost & Complexity | Generally simpler and cheaper to implement and maintain. | More complex infrastructure; can be more expensive to operate. |
By the end of this framing process, you should have a clear, concise statement that you can repeat back to the interviewer. For example: “My understanding is that we want to build a binary classification model to predict if a user will watch a given video for more than 60 seconds. We'll use user history and video metadata as inputs. We need the predictions in real-time with latency under 200ms, and we'll measure success by the impact on average session watch time.” This sets a solid foundation for the rest of the design.
When presented with a vague business goal like “improve video recommendations,” what is the most critical first step in a machine learning system design interview?
A business wants to “reduce customer churn.” Which of the following is the best example of a well-defined machine learning label () for this problem?