cloudpatterns.appClassroomKatasWhiteboardBlog
Story

Discord: billions of messages, then trillions

How Discord's message storage moved from one MongoDB replica set to Cassandra and then ScyllaDB — and the problems behind each move.

15 minMedium

Members lesson

Membership isn’t open yet. The free lessons are open — 16 of them.

What you'll be able to do

  1. 1Explain why shards add write and storage capacity where read replicas add only read capacity, and why each shard still needs replicas of its own.
  2. 2Choose a partition key and sort key that turn each listed access pattern into a single lookup or range read.
  3. 3Predict each shard's share of the requests, and what a query without the shard key costs, for a given shard key and traffic.
  4. 4Explain why adding shards doesn't cool a hot key, since every request for a key goes to the one shard that owns it.
  5. 5Choose a fix for a hot key — cache its reads, split its writes over sub-keys, or isolate it — and name what each one costs.

Inside the lesson

steps
5
questions
6
simulations
5

You guess first, then run the system and see if you were right.

Step 1 · The setup

Discord decided early on to keep all chat history forever, so people can come back to it any time, on any device. In 2015 all of it lived in one database. By 2022 it was trillions of messages on 177 database nodes.

Walk through the problems behind each change in how Discord stores messages. Decide what you would do, then see what Discord did.

Steps 2–5 are for members