KatInterview

Design a Weekly User Activity Forecasting System

Machine LearningModel answer
HardModel answerMachine Learningml-system-designfeature-engineeringmodel-serving

Last updated

Build an ML platform to forecast which users will remain active next week, supporting both batch predictions for millions of users and low-latency individual queries.

Problem

You need to architect a machine learning platform that forecasts whether individual users will engage with a streaming service during the following seven days. This forecast powers retention marketing initiatives.

What the System Must Do

  • Compute weekly activity forecasts for the entire active user population
  • Expose an endpoint allowing internal teams to retrieve individual user forecasts with minimal delay
  • Handle predictions for recently registered users who lack historical patterns

Scale and Performance Targets

  • User base: 500+ million monthly active accounts
  • Batch processing: Complete predictions for all users weekly
  • Real-time queries: Respond within 100 milliseconds at the 99th percentile
  • Event-driven updates: Re-score users when significant profile changes occur

Your Design Should Address

  1. Data infrastructure: How you'll process behavioral telemetry streams and organize features for training and inference
  2. Modeling approach: Algorithm selection, temporal pattern handling, and label definition strategy
  3. Inference architecture: How batch scoring differs from online serving, and the trade-offs involved
  4. Operational resilience: Detecting distribution shift, handling degraded states, and maintaining system health

Available Resources

  • Distributed computation framework (assume Spark-equivalent capabilities)
  • Low-latency key-value storage (assume Cassandra/DynamoDB-class datastore)
  • User interaction data arrives continuously but exhibits sparsity and high cardinality

Hints

Hint 1

Think about the feature freshness requirements: which features need real-time updates versus daily batch computation?

Hint 2

Consider the difference between scoring all users weekly versus scoring one user on-demand—what can you precompute?

Hint 3

New users present a different prediction problem than established users; should you use the same model for both?