failover
← All labs

Medium · 12 steps · ~70 min

Design an email service

Send, receive, search, and never lose a message.

People search mailboxes constantly and expect every message to be stored safely. Incoming mail arrives in bursts.

Same problem as GmailOutlookProton Mail

How it works

What you'll build

  1. The API and the data behind it
  2. A server, a database and a search index
  3. A queue and workers that absorb a newsletter burst
  4. A rate limiter against a spam flood
  5. A design that survives a cold cache, a lost index node and a lost primary

Steps

  1. 1Design the API
  2. 2Design the data model
  3. 3Handle 500 requests/sec
  4. 4Handle 5,000 requests/sec for $1,000 a month
  5. 5Handle 25,000 requests/sec
  6. 6Absorb a 50,000 requests/sec mail burst
  7. 7Survive a spam flood on a budget
  8. 8Survive a cache restart
  9. 9Lose a search node
  10. 10Lose the primary database
  11. 11Mail is missing from search
  12. 12Deep dive: duplicate deliveries
Start the lab →