MentorNode
Start free
Real-Time & CollaborationHarddesign-realtime-chat

Design a Real-Time Chat System (WhatsApp / Slack)

Design a scalable real-time messaging architecture supporting 1-on-1 chats, group channels, online presence, and offline push notifications.

WebSocket GatewaySession RegistryFanoutWide-Column Storage
Traffic & Capacity Estimates:

500M Daily Active Users · 50B messages/day · Sub-100ms end-to-end delivery

Functional Requirements

  • •Send and receive 1-on-1 direct messages and group channel messages in real-time.
  • •Real-time online/offline presence tracking and read receipts.
  • •Offline message storage and Push Notifications for disconnected devices.

Non-Functional Requirements

  • •Ultra-low latency (<100ms message delivery).
  • •Zero message loss (guaranteed at-least-once delivery).
  • •Maintain persistent bidirectional connections (WebSockets) for 50M concurrent online users.

Back-of-the-Envelope Math

  • 50M concurrent WebSocket connections.
  • 50 Billion messages/day (~600,000 messages/sec peak).
  • Message storage: 50B * 200 bytes = 10 Terabytes/day.

Key Architectural Trade-offs

  • WebSocket connection state management: Zookeeper/Redis registry for mapping active user sessions to specific chat servers.
  • Message queue fanout (Kafka / RabbitMQ) for group chat message broadcasting.
  • Storage selection: Cassandra / DynamoDB (wide-column) for high-write message logs vs Redis for ephemeral presence.

Click or drag a component onto the canvas, then connect the handles to draw the data flow.

3 nodes · 2 edges

Components · 35

Client & Edge4
Compute & Gateway7
Storage & Caching11
Messaging & Streaming6
Coordination & Ops5
Intelligence2
Canvas overview