Design a Frequently Bought Together Precomputation Pipeline

Last updated: November 29, 2026

Quick Overview

Design the offline and serving system that computes, for every product, the items customers most often buy with it, and serves them on product detail pages with low latency.

Amazon
System Design
Software Engineer
Amazon
November 29, 2026
Software Engineer
Onsite
System Design
Medium

0

0

0 solved


Design the offline and serving system that computes, for every product, the items customers most often buy with it, and serves them on product detail pages with low latency.

Item-to-item co-purchase is foundational at Amazon, so onsite designers use it to test batch pipeline design over huge order data plus a simple fast lookup service. The interviewer checks pair counting at scale, normalization to avoid popular-item bias, and refresh strategy.

What the Interviewer Expects
  • Define the co-occurrence signal (same order or same session window)
  • Count pairs at scale without an explosion from huge baskets
  • Normalize scores so bestsellers do not dominate every list
  • Store top-k per item for a key-value lookup
  • Filter results for availability and policy at serve time
Key Topics to Cover
Co-occurrence Counting
MapReduce
Normalization
Key-Value Serving
Cold Start
How to Approach This
  1. Start by clarifying functional and non-functional requirements with the interviewer.
  2. Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
  3. Draw a high-level architecture first, then deep dive into 1-2 critical components.
  4. Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
  5. Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
  • How would you handle brand-new products with no purchase history?
  • How do you prevent accessories from recommending the main product's competitors?
  • How would you measure the business impact of a new scoring formula?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Functional: for each ASIN show up to 3 frequently bought together items and up to 20 related items; update daily. Non-functional: 500M ASINs, billions of order lines per year; serving p99 under 20 ms ...

High-Level Design

A daily Spark job reads orders from the data lake for the last 180 days, maps each ASIN to its parent ASIN, emits pairs from each order, aggregates counts, computes scores, keeps top-k per item, and w...


Submit Your Answer
Markdown supported