AI Hints
Home›System Design Tutorial›Shortener Design and More
System Design · Lesson 96 of 120

Chat App: Requirements

Messages in real time.

⏱ 2 min read▶ Video at 1:56:10🎓 Free
Watch this lesson in the System Design courseWatch on YouTube ↗Full System Design course

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.

Chat App: Requirements
From the video: Chat App: Requirements
  • 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.

chat_math.pypython
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")
Output
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
Next up: Chat App: Delivery — online and offline