Most teams add typing indicators as UI polish. They discover the broadcast storm when fifty users type at once.
Throttle and batch the events before you wire them into the UI, not after the database starts throwing timeouts.
We built real-time chat for clients in healthcare and customer support. A typing indicator that works for ten users silently collapses under load. The fix is always the same: decide how you sync state before you decide where the indicator appears on screen.
The mistake almost everyone makes with typing indicators
Teams treat typing state like a message. They broadcast every single keystroke to every participant in the conversation.
A user types a character. The client fires an event. The server relays it to the other side. The indicator lights up. Works perfectly in testing with two users and a local server.
Then it breaks in production. Not catastrophically - just slowly. Latency climbs. Indicators flicker. The database logs fill with presence updates that nobody asked for.
The server fans out thousands of tiny events per second.
The tell is always the same: typing events outnumber actual messages by 50:1 or more. If you have already shipped read receipts, you have seen this pattern before. Presence state generates far more traffic than content.
A typing indicator is not a message. It does not need guaranteed delivery, ordering, or persistence. Treating it like one wastes server capacity on ephemeral state.
The fix is recognizing that typing indicators are presence signals, not data - and handling them accordingly.
Why broadcasting every keystroke breaks at scale
Every keystroke triggers an event. The client fires it. The server receives it. The server broadcasts it to everyone in the conversation.
At low concurrency, this feels instant.
But each broadcast is a WebSocket message sent to every participant. A five-person chat with one active typist generates five outbound messages per keystroke. Two active typists double that. Ten people typing at the same time means 100 messages per keystroke, and typing speed averages 200 keystrokes per minute.
The math compounds fast. The server spends CPU time serializing each message. The network layer queues them. Every recipient's client deserializes and renders the update.
Most of that work produces no visible change. The indicator was already showing.
We ran into this building real-time web applications where chat was one feature among several. The typing indicator worked perfectly in staging with three test accounts. It degraded visibly at 30 concurrent users. At 80, it caused intermittent lag spikes.
The bottleneck was not the database or the API. It was WebSocket throughput handling events that conveyed no new information.
The fix is sending fewer events in the first place.
What to do instead: throttle first, then sync
Throttle on the client before you send anything to the server. Every keystroke triggers a local state change. Only one update every two or three seconds goes over the wire.
The server receives a boolean: is_typing: true or is_typing: false. That is the only state it needs to broadcast to other participants. When the client stops typing for a few seconds, send is_typing: false and clear the indicator.
This pattern works for cross-platform messaging apps where users join from different devices and connection quality varies. The throttle absorbs the noise. The server only handles the signal that matters.
Set the throttle interval based on how responsive the indicator needs to feel. Two seconds is enough for most chat apps. Three seconds if server load is a constraint. Any longer and the indicator lags behind real behavior.
How to spot the broadcast storm before launch
Load-test with ten concurrent users typing at the same time. If your server logs show one WebSocket message per keystroke per user, you have a broadcast storm waiting to happen at scale.
The warning signs show up in three places before real users do. Your WebSocket connection count climbs faster than your user count. Each typing session holds a socket open. Server CPU spikes when multiple users type simultaneously, even with light traffic. Your database or presence store logs sudden bursts of write operations clustered around typing activity.
Check these three metrics during your load test:
- WebSocket messages per second during active typing
- Server memory usage as concurrent typing sessions increase
- Time between a keystroke and the indicator appearing for other users
The third metric matters more than the first two. If throttling adds noticeable lag to the indicator, you throttled too aggressively. The right threshold feels instant to users while cutting server load by 80% or more.
This same pattern applies to real-time state sync in voice applications. The logic that decides when to broadcast a state change is identical.
A cleaner approach from the start
Design the typing indicator as a throttled state sync from the beginning, not a direct keystroke relay.
The client detects typing activity locally. Waits a fixed interval - say 2 seconds. Then sends one "user is typing" event to the server. The server broadcasts that state to other participants. When typing stops, the client waits another brief period before sending "user stopped typing."
This cuts network traffic by orders of magnitude. A user typing a 50-word message might generate 200+ keystrokes but only 2-3 state events. The server handles fewer writes. The database logs less ephemeral data. Client performance stays smooth even in group conversations.
The throttle interval is not arbitrary. Set it based on how fast people type and how responsive the indicator needs to feel. One second feels instant but generates more events. Three seconds cuts traffic further but introduces noticeable lag. We've found 2 seconds balances both for most chat products.
Top comments (0)