Design a Learned Candidate Ranking Service
Design an online ranker and its model lifecycle for caller-supplied candidates.
Problem statement
Design a service that orders a caller-supplied set of candidate items for a request. For this exercise, assume an upstream system supplies up to 200 candidate IDs with request context, and your service returns the top 20 eligible IDs in order.
Eligibility means an item is marked active in a versioned activity view no older than five minutes; never return an item known to be inactive. A caller may show a returned item to an end user.
Optimize the probability of a qualified action within one day of an actual impression, while preserving that eligibility rule and a safe fallback. The caller reports impressions with displayed positions and later qualified actions.
Explain the request path, feature and label construction, a defensible first ranking model, offline and online evaluation, versioned rollout, and recovery when features or scoring fail. Candidate generation, user-profile recommendation, search indexing, and the caller’s presentation UI are outside this exercise.
What to build
- Given request context and a supplied candidate set, return at most 20 candidates marked active in the permitted activity view, in a stable rank order with a decision identifier and model version. Exclude any item known inactive.
- Accept impression records with displayed positions and later qualified-action records so training and evaluation can distinguish exposed items from unshown candidates.
- Refresh features and the learned model from observed data, evaluate a candidate model, and release or roll back a version without changing an in-flight decision.
- When a required scoring dependency fails or a model is unhealthy, return an eligible deterministic fallback list or a clear unavailable result.
At scale
- For this exercise, assume 20,000 peak ranking requests per second, up to 200 caller-supplied candidates per request, and a top-20 response. These bounds make feature fan-out and score batching material.
- For this exercise, assume ranking latency below 120 ms at p99 and 99.9% monthly availability. The failure path must make a bounded choice between fallback and unavailability.
- For this exercise, assume item activity changes must reach the ranking view within five minutes. Each decision records the activity-view and model versions used so later analysis is reproducible; an unavailable or older view cannot authorize a result.
- For this exercise, assume qualified actions can arrive up to one day after an impression and exposed-event data is retained for 30 days. Evaluation must wait for mature labels and account for position-dependent exposure.