Twenty thousand people open one channel, and the database answers once
transcript
Twenty thousand people open one channel. Within ten seconds. The database answers once.
A ping goes to everyone. Twenty thousand people tap the channel. All asking for the same thing. The latest 50 messages. All from one partition. On the same few replicas.
Those replicas slow down. And so does every other query routed to them. Other channels too. Discord saw hot partitions slow its entire cluster.
Cache it? Then every edit, delete and reaction must invalidate it. Discord did something simpler. Share the query already running. Nothing stale beyond that one query. Nothing to invalidate.
Every request carries the channel id. So they all land on one instance. The first request starts a query. The other 19,999 share it. One database read. Everyone gets the answer.
The hot channel lands on one cheap service instance. Not on the database, which isn't cheap. Route by the hot thing. Then share the work. Twenty thousand identical reads become one.
Full breakdown in the lecture.