Problems / Async and streaming, hard

Trending videos: top-K at 30,000 views a second

Asked at YouTube and Twitter/X. Each view increments a per-video counter row in a key-value store, and the trending page reads those counters. Views follow a power law, so one viral video hammers one partition; at 10 s a new release doubles views.

Unlock it once for 25 credits; everything inside it is free (runs, changes, Submit, results, hints). Sign in with Google to start; new accounts get free credits.

Your goals

Success ≥ 99.5%, p99 ≤ 400 ms and Apdex ≥ 0.90, for at most $26,000 a month.

Test cases

Like a coding problem, a solution has to pass every case, not just the one it was built for. Submit in the lab runs all 3; 1 of them are hidden until then.

  1. As given. The problem’s own traffic, scheduled failures and seed.
  2. A server dies. One replica of the service with the most replicas is killed for part of the run.

The traffic

30,000 requests a second for 20 seconds: 90% view (writes), 10% trending (reads).

The system

What each component does in this design, and what calls it. The simulator mimics each one from these settings.

ComponentIts job hereSettings
Load balancerLoad balancerTraffic enters here.Calls View API, Trending API.Layer 4 balancers route by IP and port; layer 7 balancers read HTTP and can route by path or header.–
View APIApp serviceLoad balancer forwards to it for /view.Calls View counters (DynamoDB, one row per video).Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s.12 replicas × 100 slots · timeout 1.0 s
Trending APIApp serviceLoad balancer forwards to it for /trending.Calls View counters (DynamoDB, one row per video).Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s.4 replicas × 100 slots · timeout 1.0 s
View counters (DynamoDB, one row per video)Key-value storeView API calls it. Trending API calls it.Key-value stores spread keys over partitions; one very popular key can overload a single partition.32 partitions × 2,000 ops/s

More async and streaming problems