Design Gmail from an empty canvas: send mail through SMTP workers, receive and store mail with spam filtering, read the inbox from a cache, and search every message.
Unlock it once for 15 credits; everything inside it is free (runs, changes, Submit, results, hints). Sign in with Google to start; new accounts get free credits.
What it must do
Open the inbox: the latest message headers, fast.
Send mail: accepted at once, handed to SMTP workers that deliver it to other mail servers.
Receive mail from the internet: filter spam, store the body and attachments, record its metadata.
Search every message in a mailbox.
Scale
2,000 requests a second: 1,200 inbox reads, 400 incoming messages, 200 sends and 200 searches.
A message averages 75 KB with attachments; bodies go to object storage, about 1 KB of metadata to the database.
About half of all incoming mail is spam.
Request types to route: inbox (60%, read), receive (20%, write), send (10%, write), search (10%, read). Budget: $7,500 a month.
Estimate first
Messages received a day (million)
Body storage added a day (TB)
Spam messages classified a second (msg/s)
Monthly cloud cost of your design (USD)
The test cases
You start from an empty canvas. When you run the tests, each one simulates your design with its own traffic and failures:
Test
What it does
Passes when
Normal day
The normal day: the traffic in the brief, nothing broken.
Success ≥ 99.9%; p99 latency ≤ 200 ms (inbox); p99 latency ≤ 500 ms (search)
Cache flushed
At 5 s the cache on the request path is emptied, as after a restart or a bad deploy.
Success ≥ 99%; p99 latency ≤ 500 ms (inbox)
Database 4× slower
At 5 s the main database on the request path answers 4× slower for 8 s.
Success ≥ 99%
Budget: $7,500/month
The normal day's design must cost at most $7,500 a month.
Cost ≤ $7,500/month
Must include
Object storage for message bodies. Bodies and attachments are large blobs, cheap in object storage and wasteful in a database.
A metadata database. Folders, labels, read flags and headers are small rows the inbox lists.
A queue to the SMTP senders. Delivering to other mail servers is slow and retried; it never runs on the request path.
A spam filter. Half the incoming mail is spam and must be classified before it reaches the inbox.