Design a chat app
Chat looks like a real-time problem and is really a sync problem, because the network will drop, duplicate and reorder messages no matter how good your sockets are. This works it in interview order, with per-conversation sequence numbers and per-device cursors as the two ideas that make delivery, ordering, offline catch-up and read receipts fall out of one design.
What you'll be able to do
- Size a chat system from daily users and messages, and turn the numbers into a connection count and a storage plan
- Assign per-conversation sequence numbers and explain why the counter is not a hot spot
- Use a per-device cursor for offline sync, multi-device delivery and read receipts, so one mechanism does three jobs
- Make sending idempotent with a client-generated message id, and make receiving tolerant of duplicates and reordering
- Price group fan-out and keep presence cheap enough to run for every user
Before this: real-time-updates, dynamodb-and-cassandra
Log in to read the rest of this lesson
Chat looks like a real-time problem and is really a sync problem, because the network will drop, duplicate and reorder messages no matter how good your sockets are. This works it in interview order, with per-conversation sequence numbers and per-device cursors as the two ideas that make delivery, ordering, offline catch-up and read receipts fall out of one design. This walkthrough runs about 28 minutes, with runnable code you can edit and re-run as you read. A new account gets 7 days of Pro free, no card required.
Log in to continueThe first module of every track is free to read on the web: see what's open in System design.