System Design

Chat Messaging

Design a real-time chat and messaging service like WhatsApp or Messenger.

Functional requirements

  • Users can send and receive one-on-one text messages in real time; recipients online at send time see the message within a second.
  • Users can participate in group chats of up to 500 members, with messages delivered to all members.
  • Messages sent to offline users are stored and delivered when they reconnect, with sender-visible delivery states (sent, delivered, read).
  • Users can see presence status (online / last-seen) for their contacts.
  • Clients can fetch recent conversation history when reinstalling or adding a new device.

Non-functional requirements

  • Delivery guarantee: at-least-once delivery with client-side deduplication. A message must never be silently lost once the sender sees 'sent'.
  • Ordering: messages within a single conversation must appear in a consistent order for all participants; cross-conversation ordering is not required.
  • Latency: end-to-end delivery p95 under 500ms for online recipients; message-send acknowledgment p99 under 1s.
  • Availability over strict consistency: the service should keep accepting and delivering messages during partial failures; brief staleness in presence and read receipts is acceptable.
  • Security: transport encryption everywhere; messages durable (replicated) before the sender is acked. End-to-end encryption design is out of scope but the architecture should not preclude it.

Scaling & constraints

  • 800M monthly users, 200M daily active users; a typical user sends ~40 messages/day.
  • Traffic is spiky: peak send rate is roughly 3x the daily average, concentrated in evening hours per region.
  • Average message size ~200 bytes of text plus ~300 bytes of metadata; media is out of scope.
  • At peak, ~50M users hold simultaneous open connections expecting push delivery.
  • Group chats: ~20% of messages go to groups; average group size 15, max 500.
  • Message history retained for 1 year server-side; offline queue per user must hold at least 30 days of undelivered messages.

Out of scope

  • Media upload/download (images, video, voice notes) and file storage.
  • End-to-end encryption key exchange and cryptographic protocol details.
  • Voice/video calling.
  • Spam detection, abuse moderation, and account/registration flows.

Sign in to save your progress

AI design evaluation

Get a grounded score, what your design does well, its gaps, and what to study next.

Sign in to evaluate

Sign in to get AI feedback on your design.