Skip to content
We areTOP 1%

Design a chat application like WhatsApp

HardConceptSocial Platforms
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

Requirements: one-to-one and group messaging with low latency, delivery and read receipts, online presence, delivery to offline users, and message history that persists across devices.

  • Connections: clients hold WebSocket connections to chat servers; a session registry such as Redis maps each user to the server holding their connection so messages can be routed.
  • Storage: messages go to a wide-column store such as Cassandra, partitioned by conversation ID and sorted by a time-ordered message ID, which preserves ordering within each chat.
  • Offline users: messages are stored and delivered on reconnect, with a push notification sent in the meantime.
  • Trade-off: acknowledging only after the message is persisted adds a little latency but prevents loss; group fan-out is cheap for small groups but needs care for very large ones.

More in Social Platforms

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account