KatInterview

Real-Time Multi-Vendor Price Comparison Platform

System DesignModel answer
MediumModel answerSystem Designcachingapi-designdistributed-systems

Last updated

Build a service aggregating product offers from 30+ external APIs, balancing freshness, latency, and quota limits through hybrid caching.

Problem

You're building a product price comparison platform that aggregates listings from multiple online retailers. Users search for items by identifier (like ISBN for books) or keywords, and your service returns a unified view of available offers sorted by total cost.

Context

Your platform needs to query 30+ external merchant APIs and web sources. Each merchant has different response times, rate limits, and reliability characteristics. Some provide bulk endpoints, others only support single-item lookups. Rate limits typically range from 10-100 requests per second per merchant.

System Requirements

Functional

  1. Search capability: Support lookups by unique identifier or keyword query
  2. Offer aggregation: Collect price, shipping, condition, and seller rating from all sources
  3. Ranking: Sort results by total cost (item price + shipping)
  4. Graceful degradation: Return available results even when some sources fail or timeout

Scale & Performance

  • Query load: 5,000 requests/second at peak
  • Catalog size: 50 million unique items
  • Response time: 99th percentile under 800ms
  • External timeouts: Cap at 1.5 seconds per merchant
  • Data freshness: Price data should typically be under 4 hours old

Your Task

Design the architecture for this system. Address:

  1. API design: What endpoints do you expose? What does the response structure look like?
  2. Data modeling: How do you store item metadata, offers, and pricing history?
  3. Fetching strategy: When do you query external merchants—on demand, background refresh, or both?
  4. Reliability patterns: How do you handle slow or failing merchants without impacting overall availability?
  5. Rate limiting: How do you stay within merchant quotas while serving high query volume?
  6. Cache strategy: What do you cache, where, and how do you keep it fresh?

Consider the trade-offs between freshness, latency, and cost (quota consumption).

Hints

Hint 1

Calculate the refresh rate needed to keep all 50M items fresh—it won't fit merchant quotas. You need a hybrid approach.

Hint 2

Stale-while-revalidate lets you return cached data immediately while triggering background refresh.

Hint 3

Use a popularity-based tiering system: refresh bestsellers frequently, long-tail items only on access.