How WhatsApp Shows “Typing…” in Real Time

Persistent connections, ephemeral events and global scale: how WhatsApp delivers the typing indicator without polling, database writes or history.

Dhananjay AggarwalDhananjay Aggarwal, · 8 min read
Share
Summarize with AI
Two phones showing Typing… connected through MQTT to WhatsApp servers, under the heading Inside WhatsApp’s Real-Time Typing System. From a post by Dhananjay Aggarwal.

If you’ve ever noticed how WhatsApp shows “Typing…” the moment the other person starts typing, even on slow or flaky networks, you’ve already seen a well-engineered real-time presence system at work.

WhatsApp shows “Typing…” by sending a small USER_TYPING event over a persistent MQTT connection that each phone keeps open to WhatsApp’s servers. The server pushes the event to the other person’s live socket and then discards it. Nothing is polled or written to a database, and when the events stop, the indicator clears.

What looks like a tiny UI feature is backed by:

  • Always-on socket connections
  • Event-driven messaging
  • Ephemeral, non-persistent data flow
  • Infrastructure built to handle millions of concurrent users

This article breaks down exactly how it works, from client to server, without hand-wavy explanations.

The Core Idea#

“Typing…” is not a stored state. It is a real-time signal, streamed over persistent connections, delivered instantly and discarded immediately.

No polling. No database writes. No history.

1. Persistent Connections, Not HTTP Requests#

When you open WhatsApp, the app opens a long-lived TCP socket connection to WhatsApp’s backend servers.

Instead of traditional HTTP APIs, WhatsApp relies on MQTT (Message Queuing Telemetry Transport).

Why MQTT?

  • Designed for low bandwidth and unstable networks
  • Minimal packet overhead
  • Supports bidirectional, server-push communication
  • Ideal for mobile devices that frequently switch networks

Once this connection is established, it stays alive for the whole session. The server can push events to the client instantly, without waiting for a request.

A WhatsApp client holding a persistent MQTT connection to the backend: an MQTT broker, a chat server and a presence server. From a post by Dhananjay Aggarwal.

2. How does WhatsApp know someone is typing?#

WhatsApp knows someone is typing because their app sends a lightweight USER_TYPING event over the open socket the moment they start typing.

When a user starts typing, WhatsApp does not:

  • Update a database row
  • Flip a “typing = true” flag
  • Store anything durable

Instead, the client emits a lightweight event over the existing socket.

Conceptually, it looks like this:

code
EVENT: USER_TYPING
chat_id: X
sender_id: Y

This event goes to the backend immediately.

The server then:

  1. Identifies the active participants in the chat
  2. Checks which recipients have live socket connections
  3. Pushes the event to those sockets
  4. Discards the event after delivery

The receiver’s UI listens for this event and renders “Typing…” in real time.

The sender's phone emits a USER_TYPING event with chat_id and sender_id to the MQTT broker, which pushes it to the receiver's phone, where the UI shows Typing…. From a post by Dhananjay Aggarwal.

3. Why does “Typing…” disappear when someone stops?#

“Typing…” disappears when someone stops because typing events are never stored, so once the sender’s events stop, the receiver’s UI clears the indicator.

Typing events are intentionally non-persistent.

They:

  • Are never written to databases
  • Exist only in memory
  • Expire immediately after transmission

If the sender:

  • Stops typing
  • Loses connectivity
  • Closes or backgrounds the app

The event stream stops. The receiver gets nothing further, so the UI clears the indicator.

This design prevents:

  • Stale presence signals
  • Unnecessary storage load
  • Complex cleanup logic

Ephemerality is a feature, not a limitation.

4. Does WhatsApp poll for typing updates?#

A key reason WhatsApp feels instant is that it never polls for typing updates.

Polling would mean:

  • Repeated API calls
  • Higher latency
  • Massive backend load at scale

Instead:

  • Every client stays connected
  • The server pushes events as they happen
  • The UI reacts only to incoming messages

This event-driven model is both faster and cheaper at global scale.

Side by side: polling sends frequent network requests to the server with higher latency, while a persistent socket keeps one open connection with low latency. From a post by Dhananjay Aggarwal.

5. Scaling to Millions of Concurrent Typers#

WhatsApp scales typing indicators to millions of concurrent users with Erlang-based backends, sharded connection-handling nodes and stateless routing for ephemeral events.

At any moment, millions of users across India, Brazil, Europe and beyond are typing at the same time.

WhatsApp handles this with:

  • Highly concurrent Erlang-based backend systems
  • Horizontal sharding of connection-handling nodes
  • Stateless routing for ephemeral events
  • Regional load balancers to minimize latency

Each backend node can hold millions of open socket connections efficiently.

Because typing events are:

  • Extremely small
  • Short-lived
  • Never stored

They scale linearly without becoming a bottleneck.

6. Why This Architecture Works So Well#

WhatsApp’s typing architecture works because it skips database writes, retries and synchronization guarantees for presence, which keeps latency low and infrastructure simple.

The strength of this system lies in what it doesn’t do.

  • No database writes for presence
  • No retries for lost typing events
  • No synchronization guarantees

Typing indicators are best-effort signals, not critical data. If one event is missed, the system simply moves on.

This keeps latency low and infrastructure simple.

The Key Takeaway#

“Typing…” is not magic. It is not a complex backend workflow.

It is:

  • A tiny real-time event
  • Sent over an always-on socket
  • Delivered instantly
  • Discarded immediately

This is a textbook example of event-driven system design done right.

Pairs of clients on both sides connected over persistent connections to MQTT backend servers with chat and presence services. From a post by Dhananjay Aggarwal.

Final Thought#

Small UI features often reveal the best system design lessons.

WhatsApp’s typing indicator shows how:

  • Ephemeral data should stay ephemeral
  • Persistent connections beat polling at scale
  • Real-time systems don’t need heavy persistence

If you’re designing chat apps, collaboration tools, multiplayer games or live dashboards, this pattern is worth studying closely.

Frequently asked questions#

Does WhatsApp store typing status in a database?

No. WhatsApp typing events are never written to databases. They exist only in memory and are discarded right after the server delivers them.

What protocol does WhatsApp use for real-time events?

WhatsApp uses MQTT (Message Queuing Telemetry Transport) over a long-lived TCP connection. MQTT is designed for low bandwidth and unstable networks and supports server push, which suits mobile devices that switch networks often.

Why does WhatsApp use a persistent connection instead of polling?

Polling would mean repeated API calls, higher latency and heavy backend load at scale. A persistent connection lets the server push each typing event as it happens.

What happens if a WhatsApp typing event is lost?

Nothing is retried. Typing indicators are best-effort signals, so if one event is missed, the system moves on.

Found it useful? Clap for it.
Share
Summarize with AI
Prefer IntervueClub on GoogleShow our posts more often in Top Stories
Dhananjay Aggarwal

Written by Dhananjay Aggarwal

All posts