Design a chat app
“Design a chat app” is a system design interview question. Design a chat app with one-to-one conversations and group chats of up to 100 members. Messages are text, arrive in order within each conversation, and show up on every device a user is signed in on. There are 50 million daily active users sending 2 billion messages a day, about 100,000 a second at peak. An online recipient should see a message within a second; an offline one gets a push notification, and the message as soon as they reconnect. History is kept forever. Below is what to cover and 3 hints; press Practice and Dana, the interviewer, asks it out loud while you sketch the design.
Updated · By InterviewMind
Free in your browser, no account.
The problem
System design
Design a chat app with one-to-one conversations and group chats of up to 100 members. Messages are text, arrive in order within each conversation, and show up on every device a user is signed in on.
There are 50 million daily active users sending 2 billion messages a day, about 100,000 a second at peak. An online recipient should see a message within a second; an offline one gets a push notification, and the message as soon as they reconnect. History is kept forever.
Things to cover
- How clients stay connected to receive messages
- Routing a message to the server that holds the recipient’s connection
- Storing messages, ordering them and confirming delivery
- Offline users, several devices per user, and group fan-out
Hints
Open one at a time, and try the question again after each.
Hint 1
Start with connections: if 10 million users are online at once and one server holds about 100,000 open connections, you need around a hundred connection servers, and a way to know which one each user is on.
Hint 2
The core is a persistent connection per device, a registry mapping each user to the server holding their connection, and a message store partitioned by conversation. Store the message first, then deliver it.
Hint 3
The hard part is delivery you can trust. A sequence number per conversation keeps order, clients acknowledge what they received, and on reconnect a device asks for everything after the last number it saw.
Practice it out loud
In the practice room Dana reads the question aloud in your browser’s own voice, with captions, and you answer in the editor beside it, in a design doc with the requirements filled in and a section for each part. It’s free and needs no account. Run the InterviewMind desktop app beside it and it hears the question the way it hears a real call, so you can see what it would show you in the live round.
Practice this question