How Is a Recommendation System Put Together?
A recommendation system is a pipeline: candidates are found, scored, ranked and served in milliseconds. Here is how the parts fit together.
On this page
Short answer
A recommendation system architecture is the design of the parts that turn behaviour and item data into a short ranked list: candidate generation finds a few hundred items worth scoring, a scoring model orders them, and a serving layer returns the list within a latency budget, while a feedback loop records what users do so the system can be retrained.
What is a recommendation system architecture?
A recommendation system architecture is the design of the parts that turn user behaviour and item data into a short list of suggestions, and how those parts connect. It covers how candidates are found, how they are scored and ranked, how results are served to the user, and how feedback from clicks and purchases flows back into the system.
The architecture splits into two paths. The offline path prepares data, trains models and builds indexes on a schedule. The online path answers each request in milliseconds, using the prepared models and indexes. Keeping the two paths separate is what lets a system stay fast while it keeps learning.
| Part | What it does | Where it runs |
|---|---|---|
| Candidate generation | Finds a few hundred items worth scoring | Offline and online |
| Scoring and ranking | Orders candidates by predicted interest | Online |
| Feature store | Supplies the same features for training and serving | Both |
| Serving | Returns the list inside the latency budget | Online |
Most teams start with a simple version and add parts only when the simple version shows a limit. A small shop can serve recommendations from a precomputed list, while a large catalogue needs candidate generation and real-time scoring. The design should match the catalogue size, the traffic and the team's ability to run it.
How does candidate generation work?
Candidate generation is the first stage, and its job is to shrink a catalogue of millions of items to a few hundred worth scoring in detail. It is a recall problem: the stage must not drop items the user would like, even if it also passes along some items they would not. A fast, rough method is fine here, because the scoring stage checks the candidates again.
Three methods cover most cases. Collaborative filtering finds items liked by people with similar tastes. Content-based matching finds items similar to ones the user already liked. Two-tower models learn a vector for each user and each item, then find near neighbours with an approximate nearest neighbour index, which is fast even for very large catalogues.
The number of candidates is a design choice. Passing 500 candidates to scoring gives better coverage than 100, but costs more time and compute. Teams usually start near 200 to 500 and adjust after measuring how often the best items survive the first stage. See what a recommendation system is for the filtering methods in more detail.
How do scoring and ranking work?
Scoring takes the few hundred candidates and predicts how much the user will like each one, usually as a click, purchase or watch probability. A model reads features about the user, the item and the context, such as time of day and device, and returns one score per candidate. The list is then sorted by score, so the best guess comes first.
Ranking adds rules after the model. Business rules can pin a new item near the top, hold back items that are out of stock, or limit how many results come from one seller. A second pass, often called re-ranking, can add variety so the list is not ten versions of the same thing. See how re-ranking works for that stage in more detail.
The scoring model is trained offline on logged clicks and purchases, then loaded into the serving layer. Because the model is trained on past behaviour, it can repeat past patterns, so teams check the ranked list for stale or narrow results and mix in exploration items that the model has not seen the user try.
What does the feature store do?
The feature store is the shared place where features live, so training and serving use the same numbers. A feature might be how often a user buys a category, how new an item is, or the average rating of a seller. If training uses one definition and serving uses another, the model scores items with numbers it never saw during training, and quality drops.
Features come in two speeds. Batch features are computed on a schedule, such as a user's 30-day purchase history, and stored for fast lookup. Real-time features are computed at request time, such as what the user clicked in this session. The store keeps both behind one interface, so the model code does not need to know where a feature came from.
A feature store also records how each feature was built, which matters when something goes wrong. If a feature pipeline breaks, the store can show when the values stopped updating, and the team can fall back to older values instead of serving empty features. That audit trail is one reason teams add a store before they add more models.
How does serving work at request time?
Serving is the online path that answers one request: fetch the user's features, generate candidates, score them, apply ranking rules and return the list. Each step has a time budget, and the total is usually well under a second. The slowest step is normally scoring, so teams keep the candidate count small and the model fast.
Caching cuts most of the work. Popular lists can be precomputed and stored, so a request is a lookup instead of a full pipeline run. For signed-in users the list can be cached for a few minutes, and for new visitors a generic list is served. When the cache misses, the full pipeline runs and the result is stored for the next request.
Serving also needs a fallback. If the scoring model fails or times out, the system should return a safe list, such as popular items in the user's category, instead of an error page. The fallback keeps the page working while the team fixes the fault, and it is tested on purpose rather than discovered during an outage.
How do offline training and the feedback loop fit in?
Offline training is where the models learn. Logs of clicks, purchases and skips are collected, cleaned and turned into training data, and a new model version is trained on a schedule, such as weekly. The new version is tested against the old one on held-out data before it is allowed to serve real users.
The feedback loop is what makes the system improve. Every impression, click and purchase is logged with the features that were used, so the next training run learns from real outcomes. The loop also creates a risk: the model only learns about items it showed, so teams add exploration, showing some items the model would not pick, to keep learning about the rest of the catalogue.
Feedback must be handled with care. A click is not the same as satisfaction, and optimising for clicks alone can push flashy items that users regret. Teams track longer signals too, such as purchases, returns and repeat visits, and they weight the training data so short-term clicks do not drown out real value.
How do you design a recommendation architecture in 6 steps?
Designing a recommendation architecture is a sequence of decisions, each one fixing a part of the system before the next part is built. The steps below fit a first version that a small team can run, and each step can be revisited as traffic grows. For the team process around these steps, see how to implement a recommendation system.
- Define the goal. Decide what a good recommendation means here: a purchase, a watch, a booking, and how it will be measured.
- Pick the candidate method. Start with collaborative filtering or content matching, and add a two-tower model only when the catalogue is large.
- Set up the feature store. List the features the model needs, and build the batch and real-time paths behind one interface.
- Build the serving path. Fix a latency budget, add caching for popular lists, and write the fallback list for failures.
- Add the feedback loop. Log impressions, clicks and purchases with the features used, and schedule retraining.
- Test before launch. Compare the new model with the old one on held-out data, then run a small live test before full rollout.
Keep the first version small enough to run and measure. A design that a team can operate and debug beats a larger design that only works on paper.
Example (hypothetical): a shop designs its picks system
Example (hypothetical): an online shop with 40,000 products wants a 'picked for you' row on its home page. The team sets a latency budget of 300 milliseconds and a candidate count of 300, so scoring 300 items at about half a millisecond each takes 150 milliseconds, leaving room for feature lookup and ranking.
Candidate generation uses two methods: collaborative filtering for signed-in users and popular items in the viewed category for new visitors. Scoring uses a model trained on the last 90 days of clicks and purchases. The team caches the list for 10 minutes per user, so a returning visitor in that window gets a lookup instead of a full run.
After two weeks the numbers show the picked row drives 120 orders a day from 8,000 views, which is 15 in 1,000 views. The team then adds exploration: 1 in 10 slots shows an item the model would not pick, and those slots are logged so the next training run can learn about items the model had ignored.
What are the common mistakes?
The most common recommendation architecture mistakes are training on different features than serving uses, letting the feedback loop narrow the catalogue, and skipping the fallback list. The best practices for recommendation systems cover the same ground from the operating side.
- Training-serving skew. Features defined one way in training and another way in serving make the model score with numbers it never learned from.
- No exploration. Showing only what the model already likes means new items never get data, and the catalogue slowly shrinks to the same few items.
- Optimising for clicks only. Clicks are easy to measure but a poor stand-in for satisfaction, purchases or repeat visits.
- No fallback. A scoring failure with no safe list turns into an empty page or an error, instead of a smaller but working list.
- Too many candidates. Passing thousands of items to scoring blows the latency budget, so the list arrives late or not at all.
Review the architecture when the catalogue or traffic changes. A design that worked for 10,000 items may need new candidate generation at 1,000,000, and a serving path that worked at 100 requests a second may need caching at 10,000.
Key takeaways
- Split the system into an offline path that trains and an online path that serves
- Candidate generation narrows millions of items to a few hundred worth scoring
- A feature store keeps training and serving on the same feature definitions
- Caching and a fallback list keep serving fast and working when parts fail
- Log clicks and purchases with their features, and add exploration to keep learning
Frequently asked questions
What is a recommendation system architecture?
It is the design of the parts that turn behaviour and item data into a ranked list: candidate generation, scoring and ranking, a feature store, serving and a feedback loop. The design also fixes how the parts connect, how fast each step must run, and what happens when a part fails.
How many candidates should scoring receive?
Most teams pass 200 to 500 candidates to scoring. Fewer candidates cost less time but risk dropping items the user would like, while more candidates improve coverage at the cost of latency. Measure how often the best items survive the first stage, then adjust.
What is training-serving skew?
It is a mismatch between the features used to train a model and the features used when it serves. If a feature is defined differently in the two places, the model scores items with numbers it never saw in training, and recommendation quality drops without an obvious error.
Why does a recommendation system need a fallback list?
Because scoring can fail or time out, and an empty page is worse than a simple list. A fallback, such as popular items in the user's category, keeps the page working while the team fixes the fault. It should be tested on purpose, not discovered during an outage.
How often should a recommendation model be retrained?
Weekly retraining suits most shops, since it is frequent enough to pick up new items and shifting tastes without constant churn. Faster retraining helps when the catalogue changes daily, while slower cycles suit catalogues that change little. Measure drift before changing the schedule.
What is the feedback loop in a recommendation system?
It is the flow of logged clicks, purchases and skips back into training data. The loop lets the model learn from real outcomes, but it only teaches about items the system showed, so teams add exploration items to keep learning about the rest of the catalogue.