TSTier SlateAll templates

Data & analytics

Recommendation engine - retrieve a thousand, rank twenty

Why the feed is computed in a hundred milliseconds by a model that is a day out of date.

  • System design
  • deep
  • 9 step walkthrough
  • 5 tables

Share

  • Facebook
  • X

What this board gets wrong on purpose

The tension

THE OFFLINE EVALUATION AND THE ONLINE RESULT ARE MEASURING DIFFERENT SYSTEMS AND THE BOARD DOES NOT FIX IT. Training features come from a warehouse query; serving features come from a key-value store filled by a stream, written by different people in a different language - so a model that scored better offline routinely does nothing or does harm online, and the usual gap is a few percent of feature values, which is enough. The second unresolved thing is the FEEDBACK LOOP: the model is trained on clicks that the previous model chose to show, so an item that was never shown can never be learned from, and popularity compounds into a monoculture that every offline metric will happily call an improvement. And cold start has no good answer here - a new item falls back to trending, which is exactly the signal that buries new items, so the system is structurally biased against the content it most needs to evaluate.

Requirements

Ask these before drawing anything

  • What is being optimised, in one sentence, and who agreed to it? Clicks, watch time, purchases and long-term retention give four different systems, and optimising the easy one usually damages the important one.
  • How big is the catalogue and how fast does it change? Ten thousand items that change monthly needs none of this. Ten million that change hourly needs all of it, and the difference is entirely in candidate generation.
  • How fresh must a recommendation be? If a purchase must change the next page, that is a session-level requirement and needs real-time features. If tomorrow is fine, the whole right-hand side of this board can be a nightly batch and cost a tenth as much.
  • What must NEVER be recommended? Age-restricted, region-locked, out of stock, already bought, blocked by the viewer. These are correctness rules and they belong before the model, not inside it.
  • Is there an editorial or commercial override? There always is eventually, and building it in from the start is much cheaper than retrofitting a rules engine around a model.
  • How will this be evaluated? If the answer is offline AUC only, the system will ship regressions confidently. If there is no experiment framework, there is no recommendation system - only a model.

Functional

  • Return 30 ranked items for any viewer within 100 ms at p95, including a viewer seen for the first time.
  • Retrieve candidates from at least three independent sources so that the failure of one degrades quality rather than emptying the feed.
  • Exclude what the viewer has already seen in this session and what they have interacted with recently, unless the item type says otherwise.
  • Log every impression with its position, the model version that produced it and the feature values used - without this the training data is unusable and every experiment is unattributable.
  • Retrain nightly and promote a model only after an offline evaluation and a shadow run on real traffic.
  • Support holding a percentage of traffic on the previous model, sticky per viewer, for as long as an experiment runs.

Non-functional

  • p95 end-to-end 100 ms, p99 150 ms. Past that the app shows a fallback, because a slow feed is worse than a generic one.
  • The feed must never be empty. Every failure mode degrades to trending, and trending is served from a cache that is refreshed independently of everything else on this board.
  • Feature skew between offline and online computation must be measured continuously and kept under 1 percent per feature. Unmeasured skew is the default state and it silently invalidates every offline result.
  • Model rollback must take under one minute and must not require a deploy.
  • No viewer-level data crosses a region boundary on the serving path.

Out of scope

  • Search. A query is an explicit intent and deserves a different retrieval path, even though it shares this index.
  • Ads. The auction has a different objective and a hard budget constraint, and mixing the two objectives into one score is how both get worse.
  • Explanations. Worth having, and honest ones are much harder than they look once the ranker is a gradient-boosted ensemble of four hundred features.

The rest of this board

Board preview

Available on Tier Slate

This page publishes the question. The answer — 5 more written pages, a 9-step narrated walkthrough and a 5-table schema — is the board itself, and it opens in Tierslate.

  • 5written pages
  • 9walkthrough steps
  • 5tables41 columns

5 pages behind this one

  • Capacity estimation
  • Storage estimation
  • Availability
  • How it works
  • Deployment plan
Open this board in TierslateBrowse every board

More boards

Pipelines, metrics and the lag between event and answer.

  • Ad serving - an auction inside a page load
  • Analytics pipeline - the lag between an event and the answer
  • Log aggregation - the index is bigger than the data
  • Metrics and monitoring - cardinality is the thing that kills you
All 50 templatesOpen Tierslate
Tierslate

tierslate.com

HomeTemplatesPrivacyTerms