Skip to main content

Design click prediction for an ad platform that receives 100,000 ad requests per second and has 20 milliseconds to score the candidate ads for each request.

System design · Pro 3

Short answer

Clarify how the prediction is used: bid times click probability, so calibration matters as much as ranking. Then: logged impressions joined to clicks, sparse features hashed into embeddings, a cheap first model to cut candidates and a heavier ranker, frequent incremental training, negative downsampling with recalibration, log loss offline, then revenue and calibration in an A/B test.

Deeper answer

Clarify the use first. In an auction, the expected value of an ad is roughly the bid multiplied by the predicted click probability. So the model needs well calibrated probabilities, not only a correct order.

Data: every impression is logged with its features and joined to a click within an attribution window. Clicks are rare, so negatives are downsampled and the predictions are corrected afterwards. Features are mostly sparse and high-cardinality, such as user, ad, advertiser and page ids, handled with hashing and embedding tables, plus counts over recent windows.

Serving: 20 milliseconds does not allow a large model on thousands of ads. Use a funnel. A light model or retrieval step cuts candidates to a few hundred, then a deeper model scores them in batches. The model is updated often, hourly or continuously, because new ads appear all the time.

Evaluate offline with log loss and calibration plots on later days, then A/B test revenue, click rate and advertiser value. Trade-offs: model size against latency, and freshness against stability. At scale, delayed clicks, feature logging mismatches and feedback loops that starve new ads break first.

What a strong answer covers

Answer it out loud in the mock interview about 3 min

Follow-ups to expect

Common mistakes

Learn it

ML interviews

Practice System design questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.