Skip to content
SD-22 · TOP K RANKINGS · INTERACTIVE

Break it.
Then fix it.

Turn up the downloads, watch the counters melt, and add the parts a real chart service needs. Every switch is a decision you would defend in an interview.

CHALLENGECount 200K events/s and serve chart reads with p99 under 50 ms, no errors and no gamed rankings.
StatusDOWNAt 50K events per second
Chart p998 msTarget under 50 ms
Chart lag15 min+Bots can buy a rank
Errors60%Events or reads dropped
Monthly cost$3,270Counting in the request
Store + readersLIVE
50K events/s · 13K chart views/s
traffic source
Load balancerOK
Autoscales API servers
spreading 63K/s
API servers × 9OK
Stateless
63K / 90K ops/s
Count storeDOWN
Counts only
50K writes/s · no sorts
Top-K listsGAMED
Builder + rankings cache
13K reads/s · rebuilt each minute
Every download is a database write. 50K `UPDATE … SET n = n + 1` a second, many on the same hot rows of a viral app. Append events to a log and count them off the request path.
81KLists to keep fresh3 charts × 51 categories × 176 countries × 3 windows, 200 entries each.
200×Fewer count writesCombining in memory for 10 s turns 200,000 events/s into about 1,000 writes/s.
1 minChart freshnessLists are rebuilt every minute, so a chart view is a cache read, not a sort.
1×Per user, item, dayDedupe stops one device farm from buying the top spot.
Want the reasoning behind every switch?Visual walkthroughFull write-up
Was this lab useful?Your vote tells us what to improve next.