Cracking ML Interviews

Open in the interactive study hub

ML System Design

A guide to approaching ML system design interview questions with structured frameworks and full design examples.


Table of Contents

  1. Framework for ML System Design
  2. Backend Interview Guide
  3. Key Components
  4. Scalability Considerations
  5. System Design Q&A
  6. References

Framework for ML System Design

When approaching an ML system design question, follow this structured framework:

Step 1: Clarify Requirements (5 minutes)

Ask these questions:

Step 2: Define the ML Problem (5 minutes)

Step 3: Data Pipeline (10 minutes)

Step 4: Model Selection (5 minutes)

Step 5: Serving Architecture (10 minutes)

Step 6: Monitoring and Maintenance (5 minutes)


Backend Interview Guide

If you want the broader non-ML backend concepts that often get mixed into ML system design interviews, use this companion page:

It adds a structured review of:

Use this page for the ML-specific framework and design examples, then use the backend guide as the general system design revision sheet.

For design-heavy rounds, especially senior backend, platform, or applied AI interviews, pay special attention to:


Key Components

Data Pipeline

Raw Data Sources:
├── Transactional DB (PostgreSQL, MySQL)
├── Event streams (Kafka)
├── Data warehouse (Snowflake, BigQuery)
└── Third-party APIs

ETL Pipeline:
├── Ingestion (Spark, Airflow)
├── Transformation (dbt, Spark)
├── Validation (Great Expectations)
└── Storage (S3/GCS parquet, Delta Lake)

Feature Pipeline:
├── Batch features → Offline Feature Store
├── Streaming features → Online Feature Store (Redis)
└── Feature Registry (Feast/Tecton)

Model Training

Experiment Tracking:
├── MLflow / W&B for logging parameters, metrics
├── DVC for data versioning
└── Hyperparameter optimization (Optuna, Ray Tune)

Training Infrastructure:
├── Single GPU / Multi-GPU
├── Distributed training (PyTorch DDP, DeepSpeed)
└── Cloud (AWS SageMaker, GCP Vertex AI, Azure ML)

Model Registry:
├── Versioned artifact storage
├── Staging → Production lifecycle
└── Rollback capability

Model Serving

Inference Options:
├── REST API (FastAPI + Docker + Kubernetes)
├── gRPC (lower latency, binary protocol)
├── Batch prediction jobs (Spark, Airflow)
└── Streaming inference (Kafka + model)

Serving Frameworks:
├── Triton Inference Server (NVIDIA, multi-framework)
├── TorchServe (PyTorch)
├── TF Serving (TensorFlow)
├── BentoML / Seldon (framework-agnostic)
└── KServe (Kubernetes-native)

Optimization:
├── Model quantization (INT8, FP16)
├── ONNX export for cross-platform inference
├── TensorRT for NVIDIA GPU optimization
└── Response caching for repeated queries

Monitoring

Infrastructure Metrics:
├── Latency (p50, p95, p99)
├── Throughput (RPS)
├── Error rate
└── GPU/CPU utilization

Data/Model Metrics:
├── Feature drift (PSI, KS test)
├── Prediction distribution shift
├── Performance metrics (if labels available)
└── Business KPIs

Tools:
├── Grafana + Prometheus (infrastructure)
├── Evidently AI (drift detection)
├── Arize AI / WhyLogs (model observability)
└── PagerDuty / OpsGenie (alerting)

Scalability Considerations

Read-Heavy Systems

Write-Heavy Systems

High-Throughput Inference

Low-Latency Inference


System Design Q&A

Q1: Design a movie recommendation system. 🔴 Advanced

See detailed design: Recommendation System

Summary:


Q2: Design a fraud detection system. 🔴 Advanced

See detailed design: Fraud Detection System

Summary:


Q3: Design an ML pipeline for a spam email classifier. 🟡 Intermediate

Problem definition:

Data:

Features:

Models:

Serving:

Monitoring:


Q4: Design a search ranking system. 🔴 Advanced

Problem definition:

Learning to Rank paradigm:

Features:

Model:

Evaluation:


Q5: Design a real-time content moderation system. 🔴 Advanced

Requirements:

Architecture:

Models:

Human-in-the-loop:

Monitoring:


Q6: How would you A/B test a new recommendation model? 🟡 Intermediate

Setup:

  1. Define the primary metric (CTR, conversion, session time)
  2. Define guardrail metrics (things that must not degrade)
  3. Compute minimum detectable effect (MDE) to size the experiment
  4. Randomly assign users to control (old model) and treatment (new model)
  5. Ensure consistent assignment (same user always gets same variant)

Statistical rigor:

Pitfalls:


Q7: Design a time-series anomaly detection system. 🟡 Intermediate

Use case: Detect anomalies in server metrics, financial transactions, IoT sensors

Approaches:

Pipeline:

Production considerations:


Q8: How would you handle the cold start problem in recommendations? 🟡 Intermediate

Cold start types:

Strategies for new users:

Strategies for new items:


Q9: What is the trade-off between model complexity and latency in production? 🟡 Intermediate

Latency directly impacts user experience: even small slowdowns can measurably reduce engagement and conversion, so measure the effect on your own product. Model complexity trade-offs:

Factor Simple Model Complex Model
Latency < 10ms 100ms-1s
Memory Low High
Accuracy Lower Higher
Debugging Easy Hard
Serving cost Low High

Strategies to manage the trade-off:


Q10: How do you ensure reproducibility in ML pipelines? 🟡 Intermediate

  1. Code versioning: Git tags for every production training run
  2. Data versioning: DVC or Delta Lake to snapshot training datasets
  3. Environment reproducibility: Docker containers with pinned dependency versions
  4. Seed management: Set random seeds for data splitting, model initialization, sampling
  5. Parameter logging: Log all hyperparameters (MLflow, W&B)
  6. Artifact storage: Store model files, tokenizers, preprocessors with the run
  7. Pipeline automation: Airflow/Kubeflow DAGs for reproducible training runs
  8. Testing: Unit tests for feature computation, regression tests for model outputs

Guides in This Track

Every guide in system_design/. Start with the overview above, then work through these.


References

View or edit this guide on GitHub