HLDArena
HLD-224·Search & Indexing
Medium · 1,000 pts

Real-Time Top-K Trending Topics & Bestsellers Engine

Design an Amazon Bestsellers / X Trending heavy-hitters pipeline computing sliding-window Top-K rankings (15m / 1h / 24h) from high-velocity interaction streams.

Max p99
≤ 48 ms
Availability
≥ 99.5%
Budget
≤ $5,450

Functional Requirements

  • FR-1POST /events/interactions — Ingests view/purchase/hashtag stream keyed by bucket_shard.
  • FR-2GET /trending/{region_id}?window=1h — Returns ranked Top-100 trending items with low tail latency.
  • FR-3DELETE /events/interactions/{region_id} — Supports tenant retention TTL expiry, rule updates, or stream cleanup while keeping recent rollup caches fresh.
  • FR-4Must decouple viral event floods using partitioned stream buffers and survive DB node failure.

Workload Profile

Baseline Stream26,000 Leaderboard Read RPS / 10,000 Event Write RPS
Live Event Surge75,000 Read RPS / 28,000 Event Write RPS
Active Working Set18 GB Count-Min Sketch / heap state & regional Top-K lists
Traffic DistributionSkewed reads on global/US region_id leaderboards

Consistency Model

Approximate bounded sliding-window updates (< 5s lag) acceptable using Count-Min Sketch + heap rollups.

Design Write-up
0 boxes · 0 edges
0 words
Hidden Cases #4–#7 run automatically on Submit
Case 1: Smoke & API ContractInput Workload
Read RPS
2,000 rps
Write RPS
400 rps
Key Distribution
Uniform (Low Skew)
Chaos Fault
None (Healthy Cluster)
Expected Pass CriteriaASSERTIONS
• Tail Latency: p99 ≤ 96 ms
• Availability: ≥ 99.5%
Valid end-to-end Client → Compute → Storage topology