Chat App: Requirements
Messages in real time.
Next, a chat app, like WhatsApp or Messenger. One to one chats, group chats, and messages that arrive instantly. It's a great example of real time design.

- One-to-one and groups
- Instant delivery
- Real-time design
Requirements
Functionally, users send text messages to one person or a group of up to a hundred. Messages arrive instantly when the receiver is online, and are delivered later if they're offline. Users see sent, delivered, and read ticks. Non functionally, delivery must be fast, messages must never be lost, and order must be kept within a chat.
Functional
- 1:1 and group chatOffline deliverySent, delivered, read
Non-functional
- Low latencyNever lose a messageOrder kept per chat
Chat estimates
Quick estimates. Fifty million daily users, each sending forty messages a day, at about a hundred bytes each. Run it. Over twenty three thousand messages per second, and two hundred gigabytes of new messages every day. Millions of users are online at once, each holding an open connection.
users = 50_000_000
msgs_per_user = 40
msg_bytes = 100
per_day = users * msgs_per_user
print(f"messages/sec: {per_day / 86_400:,.0f}")
print(f"storage/day: {per_day * msg_bytes / 1e9:,.0f} GB")messages/sec: 23,148 storage/day: 200 GB
Summary
The chat app needs instant delivery, offline delivery, read receipts, and no lost messages, for tens of thousands of messages a second. Next, how messages are delivered.
Key takeaways- Instant and offline
- Never lose messages
- ~23k messages/sec