Katkat

Design a CPA system for ad bidding

AppleMachine Learning Engineer · Technical Screen

Last updated

This question tests the ability to design an end-to-end Cost-Per-Acquisition (CPA) bidding system, specifically focusing on how to model conversion probabilities and handle the complexities of delayed feedback and bid pacing.

Problem Statement

Design a backend ML system for a demand-side platform (DSP) that allows advertisers to bid based on a target Cost-Per-Acquisition (CPA). The system must decide the optimal bid price for each ad impression to maximize conversions while keeping the average cost per conversion near the advertiser's target.

Requirements

  1. Functional: Given an incoming ad request, determine if the ad should participate in the auction and calculate the bid amount b.
  2. Non-functional: The system must handle high request throughput (e.g., 100k queries per second) and ensure low latency (sub-50ms inference).

Constraints

  • Conversions often have a delay (e.g., a user clicks today but installs the app 3 days later).
  • The system must account for the varying conversion rates (CVR) across different publishers and user cohorts.
  • Budgets are finite and must be managed to ensure they aren't exhausted too early or left underspent.

Your Design Should Cover:

  • Model Architecture: How do you predict CVR and handle the conversion delay in training labels?
  • Bid Logic: What is the formula to convert a target CPA into a dynamic bid price?
  • Feedback Loop: How do you handle the data pipeline for offline training versus real-time inference?
  • Scalability: How do you ensure the system remains performant at scale?

Hints

Hint 1

Consider the bid formula as b = target_CPA * predicted_CVR * alpha, where alpha is a pacing multiplier.

Hint 2

Address the conversion delay by using a 'conversion lag' adjustment or a calibrated waiting period in your training pipeline.

Hint 3

Think about using a multi-stage approach, such as a fast heuristic-based filter followed by a more complex ML model for high-value requests.

Follow-up questions

  • How would you detect and handle click or conversion fraud that artificially inflates the perceived CVR?
  • If the advertiser changes their target CPA mid-campaign, how quickly should the system adapt, and how would you implement this?
  • How does your design change if the system needs to optimize for 'Return on Ad Spend' (ROAS) instead of a flat CPA?