Chat message store system design
The problem
A chat app keeps every message forever. People open a channel and see its newest 50 messages; they scroll up for older ones.
Groups range from a few friends to hundreds of thousands of people.
Questions to ask the interviewer
How many messages?
1,000 sent a second, and 4,000 history reads: four reads for each send.
How much history?
9 TB today, and it only grows: nothing is deleted on a schedule.
What does a read need?
The newest 50 messages of one channel, in order; scrolling up asks for the 50 before.
How fast?
Under 500 ms on average.
What is the budget?
About $620 a month.
Want to try it yourself first? Play, then come back for the approach.
PlayThe design in short
A chat app never forgets. Every message a person sends stays forever. People open a channel, read its newest page, and scroll up for older messages. Nothing is deleted on a schedule, so the history only grows. The interview is about where all those messages live, and how one page comes back fast.
Count it. The brief gives 1,000 messages sent a second and 4,000 history reads a second: four reads for each send. The history is 9 TB today. Answers must come back in under 500 ms on average. Put the three numbers next to each other before you pick a store, and ask which one grows.
What a read needs. A read wants one channel, newest first, a page of 50 messages at a time. Ask which store keeps the messages of one channel together and in order, so a page takes few reads, most often one. Then ask which store makes you fetch the 50 messages one by one, and what that costs at 4,000 reads a second.
Items to draw on the whiteboard:
- the app servers that take sends and reads
- the store, and the key that decides where a channel's messages sit
- how a read finds the newest page of one channel
- where the copies of each message live, and how many a read asks
Groups are not all alike. A chat of three friends and a public group of many thousands share one design. A quiet channel gets a few messages a day; a busy one gets thousands. Ask what the biggest group does to the place that holds its messages.
Stay inside the brief. Search, attachments, edits and deletes are real follow-ups, and each makes a fair question. Keep this interview to sends and history reads.
Wire it in GonnaCrash and watch how many reads each page costs.
The post behind this problem
This problem follows Discord's engineering post, How Discord Stores Trillions of Messages. It shows the answer to every round: play first, then read it. Real systems: Cassandra, ScyllaDB.
Last updated 24 October 2026