Bird
Raised Fist0

Ad Auction System - Ranking Ads by Expected Value

SYSTEM-DESIGNhardInterview freq: high
Choose your preparation mode6 modes available
๐ŸŽฏ
Design an Ad Auction System for Ranking Ads by Expected Value
45 min ยท senior
senior

You are tasked with designing an ad auction system for a platform with 50M DAU. The system must rank ads by expected value, considering both click-through rate (CTR) and bid amount. The P99 latency SLA is 100ms for ad ranking. You have a team of 5 engineers and 8 months to deliver. Historical click data is available, but bid data is only available in real-time.

  • 50M daily active users
  • P99 latency SLA of 100ms
  • Historical click data available
  • Real-time bid data
  • Team of 5 engineers, 8-month timeline
๐Ÿ“‹
Guided Steps
1/5
Step 1
Data Pipeline Design
How will you design the data pipeline to handle both historical click data and real-time bid data?
๐Ÿ’ก Hint
Consider the trade-offs between batch processing for historical data and streaming for real-time data.
Use a hybrid pipeline with batch processing for historical data and streaming for real-time bid data to balance latency and data freshness.
Mid: Proposes separate pipelines for batch and streaming. Senior: Integrates both pipelines with a unified feature store to ensure consistency and low latency.
โš ๏ธCommon Wrong Answer
Using only batch processing, which would fail to incorporate real-time bid data, leading to outdated rankings.
Step 2
Model Selection
What model architecture will you choose to rank ads by expected value, and why?
๐Ÿ’ก Hint
Think about the latency implications of complex models versus simpler ones.
Choose a two-tower model to efficiently handle user and ad features separately, minimizing online feature lookup latency.
Mid: Suggests a gradient boosting model. Senior: Chooses a two-tower model for its scalability and explains how it reduces inference latency compared to gradient boosting.
โš ๏ธCommon Wrong Answer
Selecting a deep neural network without considering its high inference latency, which could breach the 100ms SLA.
Step 3
Offline and Online Metrics
Which metrics will you use to evaluate the model offline and online?
๐Ÿ’ก Hint
Consider metrics that align with both model performance and business objectives.
Use PR-AUC for offline evaluation due to imbalanced click data, and CTR combined with revenue impact for online evaluation.
Mid: Mentions CTR as a key metric. Senior: Distinguishes between offline (PR-AUC) and online (CTR + revenue) metrics, explaining their relevance.
โš ๏ธCommon Wrong Answer
Focusing solely on CTR without considering revenue impact, which could lead to suboptimal ad ranking.
Step 4
Serving Architecture
How will you design the serving architecture to meet the 100ms latency requirement?
๐Ÿ’ก Hint
Consider the trade-offs between pre-computed embeddings and real-time feature computation.
Implement a pre-computed embedding strategy to minimize real-time computation and meet latency requirements.
Mid: Proposes a basic serving setup. Senior: Details a pre-computed embedding strategy and quantifies latency improvements.
โš ๏ธCommon Wrong Answer
Relying on real-time feature computation, which would likely exceed the 100ms latency SLA.
Step 5
Monitoring and Feedback Loop
What monitoring and feedback mechanisms will you implement to ensure system reliability and performance?
๐Ÿ’ก Hint
Think about how to detect and respond to distribution shifts and model drift.
Implement real-time monitoring for CTR and revenue changes, and set up alerts for distribution shifts in bid data.
Mid: Suggests basic monitoring of CTR. Senior: Proposes comprehensive monitoring including distribution shift detection and automated retraining triggers.
โš ๏ธCommon Wrong Answer
Neglecting to monitor bid data distribution shifts, leading to undetected model drift and performance degradation.
๐Ÿ“Š
Scoring Rubric
โ–ผ Show
Must Have - 60%
  • Hybrid data pipeline design that handles both batch and streaming data.
  • Model selection that considers both latency and scalability, such as a two-tower model.
  • Clear distinction between offline (PR-AUC) and online (CTR + revenue) metrics.
  • Serving architecture that meets the 100ms latency requirement with pre-computed embeddings.
Good to Have - 30%
  • Unified feature store for consistent data access across batch and streaming pipelines.
  • Explanation of how the two-tower model reduces inference latency.
  • Comprehensive monitoring strategy including distribution shift detection.
  • Automated retraining triggers based on real-time performance metrics.
Bonus - 10%
  • Quantification of latency improvements with pre-computed embeddings.
  • Integration of a feedback loop for continuous model improvement.
  • Consideration of alternative models and their specific trade-offs.
โœ…
Model Answer
โ–ผ Reveal

The ideal solution involves a hybrid data pipeline that processes historical click data in batch and real-time bid data in streaming. A two-tower model is selected for its ability to handle user and ad features separately, minimizing latency. Offline metrics like PR-AUC are used to evaluate model performance, while online metrics such as CTR and revenue impact are monitored in real-time. The serving architecture uses pre-computed embeddings to meet the 100ms latency SLA, and comprehensive monitoring is set up to detect distribution shifts and trigger retraining.

  • Hybrid data pipeline with batch and streaming components to handle different data types.
  • Two-tower model for efficient feature handling and reduced inference latency.
  • Use of PR-AUC for offline evaluation and CTR + revenue for online monitoring.
  • Pre-computed embeddings in the serving architecture to meet latency requirements.
Ignoring real-time bid data by relying solely on batch processing.
Selecting a model with high latency without considering SLA constraints.
Focusing only on CTR without considering the broader business impact.
Failing to monitor for distribution shifts, leading to undetected model drift.

Practice

(1/5)
1. In the context of anomaly detection, which of the following best describes the primary advantage of using an Isolation Forest over an Autoencoder?
easy
A. Isolation Forests require labeled data for training.
B. Isolation Forests are more suitable for detecting anomalies in time-series data.
C. Isolation Forests can handle high-dimensional data better than Autoencoders.
D. Isolation Forests are more interpretable and require less feature engineering.

Solution

  1. Step 1: Understand the strengths of Isolation Forests.

    Isolation Forests are known for their simplicity and interpretability, as they isolate anomalies by randomly selecting a feature and then randomly selecting a split value between the maximum and minimum values of that feature.
  2. Step 2: Eliminate wrong options.

    Isolation Forests require labeled data for training. is incorrect because Isolation Forests do not require labeled data. Isolation Forests can handle high-dimensional data better than Autoencoders. is incorrect because Autoencoders are generally better suited for high-dimensional data. Isolation Forests are more suitable for detecting anomalies in time-series data. is incorrect because Isolation Forests are not inherently designed for time-series data.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Isolation Forests = simplicity and less feature engineering [OK]
Hint: Isolation Forests = simplicity and less feature engineering [OK]
Common Mistakes:
2. When choosing between Isolation Forest and Autoencoder for anomaly detection, which scenario favors using an Autoencoder?
medium
A. When the dataset is small and labeled.
B. When interpretability of the model is crucial.
C. When the anomalies are expected to be in high-dimensional data.
D. When the dataset is large and unlabeled.

Solution

  1. Step 1: Consider the strengths of Autoencoders.

    Autoencoders are particularly effective for high-dimensional data due to their ability to learn complex representations.
  2. Step 2: Eliminate wrong options.

    When the dataset is small and labeled. is incorrect because Autoencoders require more data to train effectively. When interpretability of the model is crucial. is incorrect because Autoencoders are less interpretable than Isolation Forests. When the dataset is large and unlabeled. is incorrect because Autoencoders are computationally intensive and may not be ideal for very large datasets.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Autoencoder = high-dimensional data strength [OK]
Hint: Autoencoder = high-dimensional data strength [OK]
Common Mistakes:
3. When evaluating LLMs, why might you choose human evaluation over LLM-as-Judge?
medium
A. Human evaluation is faster and more scalable.
B. LLM-as-Judge provides more consistent results.
C. Human evaluation is less subjective.
D. LLM-as-Judge is biased towards its training data.

Solution

  1. Step 1: Compare human evaluation and LLM-as-Judge

    LLM-as-Judge can be biased by its training data, while human evaluation can provide diverse perspectives.
  2. Step 2: Eliminate wrong options

    Human evaluation is not faster or more scalable, and it is more subjective than LLM-as-Judge.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    LLM-as-Judge bias vs. human diversity. [OK]
Hint: LLM-as-Judge bias vs. human diversity. [OK]
Common Mistakes:
4. As the user base scales 10x, which component of a DLRM-based CTR prediction system is most likely to become a bottleneck?
hard
A. Data preprocessing pipeline
B. Training data storage capacity
C. Model inference latency
D. Embedding table size

Solution

  1. Step 1: Consider scaling effects on components.

    Embedding tables grow with user and feature diversity.
  2. Step 2: Eliminate wrong options.

    Preprocessing (A) and inference (B) scale with compute resources. Storage (D) is less critical than real-time constraints.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Embedding tables grow with scale. [OK]
Hint: Embedding tables grow with scale. [OK]
Common Mistakes:
5. As the number of LLMs evaluated increases tenfold, which component of the evaluation system is most likely to fail first?
hard
A. Human evaluator availability
B. Benchmark task diversity
C. Data storage capacity
D. LLM-as-Judge processing power

Solution

  1. Step 1: Analyze scalability of components

    Human evaluators are a bottleneck as scaling requires more human resources.
  2. Step 2: Eliminate wrong options

    Data storage and processing power can be scaled with infrastructure, and task diversity is not a direct scalability issue.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Human evaluators are the bottleneck in scaling. [OK]
Hint: Human evaluators are the bottleneck in scaling. [OK]
Common Mistakes:
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard