Real-World Production Deep Dives: Real-Time Chat App & Messaging

โš ๏ธ Not yet source-checked. These case studies summarize public engineering posts and talks, and some details may be simplified or wrong. Before you repeat a specific number or design in an interview, check it against the company's own write-up. Found an error, or a source that confirms a section? Add it to the tracking issue. Sourced fixes are the most welcome contribution here.

Deep-dive architectural dissections of how Google (Google Chat / Meet / FCM), Netflix (Push Messaging Service), WhatsApp, and Discord scale real-time bidirectional messaging infrastructure to billions of concurrent devices.


๐Ÿข Deep Dive 1: How Google Scales Real-Time Messaging (Google Chat, Meet & FCM)

1. Production Context & Scale

2. The Core Problem at Google Scale

3. Google's Architecture: Multiplexed Connection Service & Cloud Pub/Sub

[ Android / iOS / Web Client ]
              โ”‚
    Single Shared Persistent Connection (TLS / ALPN / HTTP/2)
              โ”‚
              โ–ผ
[ Google Front End (GFE) / Ingress Gateway ]
              โ”‚
              โ–ผ
[ Firebase Cloud Messaging (FCM) Connection Server ]
  โ”œโ”€โ”€ Manages 2B+ Ephemeral Device Registrations
  โ”œโ”€โ”€ Instant Device Wakeup via Push Tokens
  โ””โ”€โ”€ In-Memory Session Routing Table
              โ”‚
              โ–ผ
[ Google Cloud Pub/Sub & Spanner Storage ]
  โ”œโ”€โ”€ Pub/Sub routes chat messages to online recipient workers
  โ””โ”€โ”€ Spanner commits message history with TrueTime linearizability

A. The Single Multiplexed Device Tunnel

B. Spanner TrueTime for Global Chat Ordering


๐ŸŽฌ Deep Dive 2: How Netflix Uses Real-Time Messaging (Netflix Push Messaging Service)

1. Production Context & Scale

2. Netflix's Push Architecture

[ Smart TV / Mobile App ]
             โ”‚
   Long-Lived WebSocket / SSE Connection
             โ”‚
             โ–ผ
[ Netflix Edge Gateway (Zuul Push Fleet) ]
  โ”œโ”€โ”€ Netty Asynchronous epoll EventLoop
  โ”œโ”€โ”€ Connection Registry in Redis / DynamoDB
  โ””โ”€โ”€ Ephemeral Client Session Registration
             โ”‚
             โ–ผ
[ Apache Kafka Messaging Bus ]
             โ”‚
             โ–ผ
[ Internal Microservices (e.g. Playback State, Live Engine) ]

A. Zuul Push Cluster

B. Cross-Device Handoff via Ephemeral Session Registry


๐Ÿ’ฌ Deep Dive 3: How WhatsApp Scales to 2+ Billion Users (Erlang BEAM & FreeBSD)

1. Production Context & Scale

2. WhatsApp's Architecture: The Erlang BEAM Actor Engine


๐ŸŽฎ Deep Dive 4: How Discord Scales Real-Time Guilds (Elixir & Rust Architecture)

1. Production Context & Scale

2. The Solution: Elixir Processes + Rust NIFs


โš–๏ธ Comparative Architecture Matrix

Architectural Dimension Google (Chat & FCM) Netflix Push Service WhatsApp Discord
Primary Protocol HTTP/2 multiplexed / gRPC WebSockets / SSE over Netty Proprietary Noise / TCP WebSockets
Message Storage Persistent (Spanner) Ephemeral push alerts Ephemeral store-and-forward Persistent (ScyllaDB)
Connection Model Unified OS-level tunnel Dedicated Zuul edge push fleet Erlang lightweight processes Elixir actors + Rust NIFs
Ordering Model TrueTime Linearizability Event sequence timestamps Monotonic per-chat sequence Snowflake IDs per channel
Target Scale 2B+ Android/iOS devices 100M+ TV & mobile apps 2B+ users, 100B msgs/day 100M+ concurrent users

๐ŸŽฏ System Design Interview Takeaways

  1. Explain the C10K / C1000K Solution: Explain that scaling millions of chat sockets requires event-driven non-blocking I/O (epoll/kqueue, Netty) or lightweight user-space actors (Erlang/Elixir, Go goroutines) to prevent OS thread stack exhaustion.
  2. Ephemeral vs Persistent Storage: Differentiate between Store-and-Forward architectures (WhatsApp, where messages are deleted upon ACK) and Persistent Event Stores (Discord/Slack, where messages are permanently archived in ScyllaDB/Cassandra).
  3. Presence Optimization: Always propose Viewport / Lazy Presence Subscriptions to prevent the catastrophic O(N) fanout problem in large community channels.