Notes

Offline Recommendation

Some recommendations do not have to be computed while the user waits. If a homepage shelf changes once a day, you can score it overnight for every user, write the results to a key-value store, and serve the page with a single lookup. That is offline recommendation: the ranking work happens in a batch job, ahead of the request.

How the batch path works
A scheduled job reads the interaction table, refreshes user and item representations, scores candidates per user, and writes the top few hundred item ids per key into a store the serving tier reads — Redis, Cassandra, or a cached table. Serving then costs one fetch, so the expensive model runs on a cluster with no latency budget at all.

What it buys and what it costs

  • Cheap, predictable serving — a lookup per request whatever the model's size; an implicit ALS factorisation over the full user-item matrix is affordable here and impossible per request.
  • Staleness — the list reflects behaviour as of the last run, so anything a user did since is invisible to it.
  • No row for new users — anyone created after the batch ran has nothing stored, which is why batch shelves are paired with an online fallback.

Where it still wins
Slow-moving surfaces — weekly digests, email campaigns, the "related items" strip on a product page — are better precomputed, and most production systems run both paths: batch for the stable component, online scoring for whatever must react inside the session. Note that this is a question of where computation happens, not of how a system is measured, which is what offline evaluation means.

Offline recommendation computes recommendations in advance in a batch job and stores them, so a request is answered by a lookup rather than by running a model. This removes the serving latency constraint, making whole-matrix methods like ALS practical, and keeps per-request cost flat. The trade-off is staleness: the list reflects only behaviour seen by the last run, and users created since have no entry at all.

Think of a shop that lays out its shelves before opening, based on what customers bought last week. Nobody is rearranging anything while you walk around — the work was done the night before. Offline recommendation works like that. A computer goes through everyone's history overnight, decides what to suggest to each person, and saves the answers. When you open the app, it simply reads your saved list, which is why it appears instantly. The downside is that the list was made before today happened, so whatever you did this morning has not changed it yet.