failover
← All labs

Medium · 12 steps · ~70 min

Design a ranked feed

Votes pouring in, and a ranking that stays fresh and fair.

Posts are ranked by votes and age. Reads are constant and votes arrive in a flood.

Same problem as RedditHacker NewsProduct Hunt

How it works

What you'll build

  1. The API and data for posts and votes
  2. A system that answers 800 requests a second
  3. A cached front page within a budget
  4. A queue and workers that tally votes
  5. A design for a viral post and a rate limiter against vote bots
  6. A system that survives a cold cache, a lost server and a lost primary

Steps

  1. 1Design the API
  2. 2Design the data model
  3. 3Handle 800 requests/sec
  4. 4Cache the front page for $900 a month
  5. 5Queue the votes at 30,000 requests/sec
  6. 6A viral post at 100,000 requests/sec for $2,000
  7. 7How fresh should the ranking be?
  8. 8Survive vote brigading on $2,200
  9. 9Survive a cache restart
  10. 10Lose an API server
  11. 11Lose the primary database
  12. 12Deep dive: a retried vote counts twice
Start the lab →