WhatsApp uses XMPP (an XML-based messaging protocol) over persistent TCP connections. Its server architecture is built in Erlang, chosen for its ability to maintain millions of concurrent lightweight processes. The messaging layer is a simple store-and-forward — no database write per message, just in-memory delivery with async persistence.
Slack uses a proprietary WebSocket-based protocol. Messages are stored in a PostgreSQL database and indexed in Elasticsearch. The connection layer is separate from the storage layer. Slack’s threading model requires more complex message ordering than simple chat.
Discord serves gaming communities with very large group chats (servers with 100K+ members). Their architecture diverges from simple 1:1 chat — a single message in a large server fan-outs to all active members. They use a combination of WebSockets and WebRTC for voice/video. Discord’s engineering blog describes their move from MongoDB to Cassandra for message storage, motivated by write amplification at scale.
Concept: Real-Time Chat System
Thread: T4 (Queues) ← Ch 5 (Message Queue) → Ch 15 (Notifications); T9 (Consensus) ← Ch 3 (Distributed KV Store) → Ch 17 (Payment Processing)
Core Idea: Persistent WebSocket connections eliminate polling; a connection registry routes messages between servers; monotonic sequence numbers per conversation maintain ordering; offline delivery queues guarantee no message is lost when recipients are offline.
Tradeoff: AT9 — Correctness vs Performance: exactly-once delivery requires distributed transactions; at-least-once with client-side deduplication provides equivalent user experience at lower cost.
Failure Mode: FM7 — Thundering Herd: simultaneous reconnection of all clients after a server restart overwhelms the restarted server; exponential backoff with jitter distributes reconnection load.
Signal: When users expect sub-second message delivery with ordering guarantees and the system must maintain billions of persistent connections simultaneously.
Maps to: Reference Book, Framework 6 (System Archetypes)