What Is a Typing Indicators Service?
A typing indicators service detects when a user is actively composing a message and broadcasts that signal to other participants in the same conversation. It is a real-time, ephemeral feature seen in chat apps like WhatsApp, Slack, and iMessage. The challenge is delivering low-latency signals without overloading the server with a keypress-per-event stream.
Data Model
Typing state is purely ephemeral. No durable database is needed; Redis alone is sufficient.
Redis Key Patterns
typing:{conversation_id}:{user_id} STRING value = 1, TTL = 5s
typing:{conversation_id} SET members = { user_id, ... } (active typists)
Event Schema (Kafka / WebSocket message)
{
event: typing_start | typing_stop,
conversation_id: STRING,
user_id: BIGINT,
timestamp_ms: INT64
}
Core Algorithm: Debounce and TTL
The client does not send an event on every keystroke. Instead it uses a debounce strategy:
- First keystroke: Client emits a
typing_startevent immediately. - Subsequent keystrokes: Client resets a 3-second idle timer but sends no additional events.
- Idle timeout: If the user stops typing for 3 seconds the client emits
typing_stop. - Server TTL safety net: The server sets
SET typing:{conversation_id}:{user_id} 1 EX 5on eachtyping_start. Even if the client disconnects without sendingtyping_stop, Redis expires the key after 5 seconds, automatically clearing the indicator.
Fanout Workflow
- The API gateway receives the typed event over WebSocket and publishes it to Kafka topic
typing.events. - A fanout service reads from the topic, looks up all online participants in the conversation, and filters out the sender.
- For each recipient the fanout service publishes a push notification to the recipient's gateway node using an internal channel (
notify:{user_id}). - The recipient's gateway delivers the
typing_startortyping_stopevent over the open WebSocket.
Failure Handling
- Client disconnect: The Redis TTL (5 s) clears the typing flag automatically. Recipients see the indicator disappear within 5 seconds at most.
- Gateway crash: The client reconnects, re-registers presence, and reissues
typing_startif still composing. Stale Redis keys expire on their own TTL. - Kafka lag: Typing events are low-priority and can be dropped during extreme lag using a short retention policy (e.g., 60 seconds). Stale indicators self-correct via TTL expiry.
- Redis node failure: With Redis Cluster, the affected shard's keys are unavailable briefly. Typing indicators disappear for users hashed to that shard until the shard recovers or is replaced.
Scalability Considerations
Typing indicators are high-frequency but tiny. The main concerns are fan-in write volume and fan-out delivery latency.
- Debounce on client: Reduces upstream event rate from ~10 events/second per user to roughly 1 event per 3 seconds. This single optimization cuts server load by an order of magnitude.
- Coalesce in the fanout service: Batch multiple typing events for the same conversation within a 100 ms window before delivering to recipients.
- Group chat scaling: For large group conversations (1,000+ members) limit typing indicator fanout to the visible participant list in the client's viewport. Server-side, cap fanout at 200 recipients per event.
- Stateless services: Gateway and fanout nodes hold no local state. Horizontal scaling is straightforward behind a load balancer.
Summary
A typing indicators service is a lightweight but latency-sensitive component. Client-side debouncing and server-side TTL-based expiry together eliminate the two main failure modes: event storms from rapid keystrokes and stuck indicators from abrupt disconnects. Redis ephemeral keys, Kafka for reliable fanout, and stateless gateway nodes give the system the headroom to scale to millions of concurrent conversations.
See also: Meta Interview Guide 2026: Facebook, Instagram, WhatsApp Engineering
See also: Snap Interview Guide
See also: Atlassian Interview Guide