Design a Top K Rankings
Design the service behind an app store’s top charts or a shop’s bestseller lists. Every download or purchase counts towards an item’s rank, and readers see the top 200 items for a chart, such as top free, top paid or top grossing, filtered by category and country, over the last hour, day or week.
The store sees 1 billion ranking events a day across 5 million items, with launch-day spikes far above the average, and readers open charts 400 million times a day. The hard parts are counting a fast, very uneven stream without a hot row for every viral app, keeping about 81,000 lists fresh within a minute, and stopping bot farms from buying a place in the chart, since a top spot is worth real money.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1What counts towards a rank?
- 2How fresh must a chart be?
- 3Which time windows?
- 4How many lists?
- 5Must counts be exact?
- 6Where do events come from?
- 7Can one user boost an app by installing it again and again?
- 8Do developers need their rank history?
How to spend the 45 minutes
- 5minPart 1: Requirements and scope
- 5minPart 2: Estimates
- 5minPart 3: API
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Deep dives and trade-offs