Design a High-Throughput Product Catalog Sync Pipeline
System DesignModel answerLast updated
Architect an async ingestion system that handles billion-scale bulk feed files and real-time single-item edits, prioritizing price/stock updates over heavy image processing.
Background
A large shopping platform lets sellers keep their product listings current through two channels: periodic bulk data files (CSV, TSV, or XML exports containing up to several million rows) and an always-on REST API for immediate one-off changes — like instantly flagging an item as sold out.
Both channels feed the same downstream catalog, which powers search, recommendations, and shoppable surfaces. Your task is to design the pipeline that takes data from both sources and makes it reliably visible downstream.
What You Are Building
Design a scalable, asynchronous product catalog update pipeline that can handle:
- Bulk feed ingestion: Files submitted by merchants on a schedule or via webhook, each potentially containing up to 10 million product rows.
- Real-time single-item edits: A low-latency REST API for immediate attribute changes (price, stock level, title, etc.).
- Two-tier SLA:
- Price and availability changes must propagate downstream within 2 minutes.
- Non-critical fields (descriptions, secondary metadata) and image work (fetching URLs, resizing into multiple resolutions, deduplication) may take up to 2 hours.
- Conflict resolution: A bulk file generated hours ago may still be processing when a merchant also submits a real-time edit to the same item. The correct final state must win.
Scale and Constraints
| Dimension | Target |
|---|---|
| Total active products | 1 billion across 1 million merchants |
| Average update rate | ~100 million products per day |
| Peak burst | Up to 50,000 updates/second during morning ingestion windows |
| API availability | 99.99% uptime |
| Feed files | Up to 10 million rows per merchant per run |
Additional constraints worth addressing:
- Bulk files frequently re-submit unchanged data. Redundant writes, database updates, and external image downloads must be avoided.
- Availability SLAs apply only to the single-item API; bulk worker pipelines must be fault-tolerant but not strictly real-time.
What to Cover
Structure your answer around these areas:
- End-to-end architecture — ingestion service, file chunking, queuing, worker tiers, and the image processing pipeline.
- Storage and data model — primary catalog store vs. staging, supporting both write bursts and fast point lookups.
- Prioritization mechanism — how critical fields (price, stock) skip or bypass the slower content and image pipeline.
- Conflict resolution — handling out-of-order writes and races between bulk feeds and real-time API edits.
- Cost and efficiency optimizations — delta detection, hashing, and deduplication strategies.
A strong answer will move from back-of-envelope estimates to API design, architecture diagram, storage choices with explicit trade-offs, and a concrete conflict resolution strategy backed by a data model.
Hints
Hint 1
Before jumping into components, derive concrete numbers first: average and peak write rates, estimated catalog size on disk, and image object count. The design decisions — queue partition counts, worker fleet sizing, storage choice — should follow directly from those numbers. Interviewers notice when the architecture floats free of the scale it is supposed to handle.
Hint 2
Think about splitting each product update by field group rather than treating the whole row as one atomic unit. Price and stock are tiny payloads that must move fast; image resizing is compute-heavy and can lag for an hour. If both go into the same queue behind the same workers, images will always threaten the price SLA. Separation at the message level — not just at worker priority — is the cleane…
Hint 3
Conflict resolution falls apart if you use arrival time instead of event time. A bulk file generated at 8 AM but processed at 10 AM must not overwrite an API edit made at 9 AM. Think about where timestamps come from (who sets them, whether client clocks are trusted), what granularity they operate at (item level vs. field-group level), and how you make the resulting writes idempotent and replayable…
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Establish Numbers First
Design decisions should follow from scale, not precede it.
| Quantity | Estimate |
|---|---|
| Products | 1B across 1M merchants; highly skewed — a few thousand large merchants own most SKUs |
| Average write rate | 100M/day ≈ 1,200/s |
| Peak write rate | 50,000/s (≈40× average, morning feed windows) |
| Product record size | ~2 KB → ~2 TB primary catalog before replicas |
| Images | ~3 per product × 4 renditions = ~12B objects, hundreds of TB in blob storage |
| Delta rate | Typical feed: only 1–5% of rows changed — delta detection is the primary cost lever |
Clarifying questions worth raising: Do full feeds imply deletes for absent items? What does "visible downstream" mean — search index refresh, ad eligibility, Pin rendering? Is the 2-minute SLA measured from merchant submission or from file fetch completion?
2. API Surface
PUT /v1/merchants/{mid}/products/{item_id}
Body: partial field map + client_ts
Header: Idempotency-Key
POST /v1/merchants/{mid}/feeds # register feed URL + schedule
POST /v1/merchants/{mid}/feeds/{fid}/runs # webhook trigger → returns run_id
GET /v1/merchants/{mid}/feeds/runs/{run_id} # status, error counts, sample row errors
The single-item API uses an Idempotency-Key so that retried requests do not double-apply. Feed registration is separate from triggering a run so merchants can update their schedule without losing run history.
3. End-to-End Architecture
Single-item API ──► API service (stateless, multi-region) ──────────────┐
│
Cron / Webhook ──► Feed Orchestrator ──► Fetch raw file ──► S3 (raw) │
│ │
▼ ▼
Chunker (50K-row byte ranges) ──► Parse + Delta Workers
(hash comparison)
┌───────────────────────────┼──────────────────────┐
▼ ▼ ▼
Kafka: catalog.critical Kafka: catalog.content Kafka: media.fetch
(price, stock) (title, desc, attrs) (image URLs)
│ │ │
Critical writers Content writers Image fetch/resize fleet
└───────────────► Catalog store ◄────── image refs ─┘
│
Change events (CDC) ──► Search, Recs, Ads
Feed Orchestrator tracks run state (run_id, chunk count, status) in a small relational DB. Raw files land in S3 so parsing is fully replayable without re-fetching from the merchant.
Chunker splits CSV/TSV by byte range on row boundaries. XML is stream-parsed. A 10M-row feed becomes ~200 chunks, each independently retryable and processed in parallel.
Parse/Delta workers validate and normalize each row, compute a content hash, and compare it against the stored hash for that item. Only changed field groups are emitted — unchanged rows are dropped entirely. This is where most CPU and write volume are eliminated.
Kafka topics are partitioned by hash(merchant_id, item_id), giving per-item ordering within each tier. Each topic has its own consumer group and autoscales independently.
4. Prioritization: Separate by Field Group, Not Item
The worst mistake is funneling both price updates and image resizing into a single queue. Image work is slow; it will periodically exhaust worker capacity and push price updates past the 2-minute SLA.
The fix is splitting each row's changes at emit time:
- Price and stock →
catalog.critical. Payloads are ~100 bytes. Dedicated consumers with reserved headroom sized to absorb the full 50K/s peak. A lag alert fires if the topic falls more than 30 seconds behind. - Descriptions, titles, secondary attributes →
catalog.content. These can queue for up to an hour during morning bursts without any business impact. - Image URLs →
media.fetch. Image workers pull the URL, check an{url_hash → content_hash, etag}table to avoid re-downloading unchanged images, resize into renditions, and write blob references back to the catalog row.
Single-item API edits publish to the same topics. Because bulk content traffic and image work live on separate topics, they never block API-originated critical writes.
Large-merchant isolation: A single merchant's 10M-row feed should not starve smaller merchants on catalog.critical. Apply per-merchant token buckets in the delta workers, or route bulk-originated critical writes to a separate critical.bulk topic so that API critical edits always have their own lane.
5. Storage and Data Model
Primary catalog: wide-column store (Cassandra, HBase, or DynamoDB). These handle high write throughput, horizontal scaling, and per-column conditional updates — all required properties here.
Row key: merchant_id | item_id (hashed prefix to spread hot merchants)
Columns:
crit:price, crit:currency, crit:availability, crit:qty + per-field timestamp
content:title, content:description, content:brand + group timestamp
attrs:custom (JSON map for merchant-specific fields)
media:images [{url_hash, content_hash, renditions, status}]
meta: row_hash, crit_hash, content_hash, img_url_hash,
last_feed_run_id, soft_deleted
Hash table (merchant|item → field-group hashes, ~40 bytes × 1B rows ≈ 40 GB) lives in the same row or a compact side table. Delta workers batch multi-get hashes per chunk before deciding what to emit.
Staging (S3, Parquet): raw files and parsed chunks with a retention TTL. Supports replay, audits, and merchant-facing error reports. Never stage in the OLTP store.
Images (S3 + CDN): keyed by content hash so identical images shared across merchants are stored once. The url_hash lookup prevents re-fetching URLs that haven't changed.
6. Conflict Resolution
The rule: per-field-group last-writer-wins on source event time, never on arrival time.
Why arrival time fails: A bulk file snapshotted at 08:00 may be parsed at 09:10. If arrival time wins, it overwrites an API stock edit made at 09:05, producing an incorrect catalog state.
Timestamp assignment:
- Bulk rows use the feed's declared snapshot time (or fetch-start time as a fallback). Never trust row-level timestamps from merchant files — they are unverified.
- API edits use server receipt time, assigned by the ingestion service. Client-supplied timestamps are ignored.
Conditional write pattern: Every writer executes a compare-and-set:
UPDATE catalog
SET price = ?, price_ts = ?
WHERE item_id = ? AND price_ts < ?
If the stored timestamp is already newer, the write is silently dropped. This makes all writes idempotent and re-runnable safely.
Field-group granularity is essential. Item-level LWW would force a choice: accept the whole bulk row or reject the whole bulk row. Field-group granularity lets the bulk feed's description change land while its stale availability write is correctly discarded.
Tie-breaking: (source_ts, source_priority, sequence_number). API edits outrank feed writes at equal timestamps. Kafka partitioning by item guarantees ordering within a single source.
Full-feed deletions: Items absent from a full feed are soft-deleted with ts = snapshot_ts. Skip the deletion if a newer API edit exists. Add a safety circuit breaker: if more than ~20% of a merchant's catalog would be deleted in one run, pause the job and alert. A truncated file upload is a common operational accident.
7. Common Mistakes to Avoid
- Hashing at the file level rather than at the row or field-group level — you lose all delta detection granularity.
- Using a relational DB as the primary catalog store — row-level locks and schema migrations do not survive 50K writes/second.
- One queue for everything — image processing latency will bleed into price SLAs every time the image fleet saturates.
- Trusting merchant-supplied timestamps — merchants often backfill or replay feeds with stale timestamps. Always assign event time server-side for the sources you control.
- Skipping the large-merchant isolation story — one merchant with a 10M-row feed is a realistic scenario and a common follow-up question.