System design
Design a chat app
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