In a dating app's mobile chat, how should the client send typing indicators and read receipts without flooding the connection or misleading the match?
answer
- one signal fades, the other must land
- throttle typing, expire it locally
- never queue or push a typing event
- read up to here, not per message
- receipts only move forward
basics
~20 sTyping is ephemeral: send it at most every few seconds over the live socket only, never queued, and let the receiver expire it. Read receipts are durable but cumulative: one 'read up to sequence N', sent when messages are actually seen.
solid answer
~50 sThe two signals need opposite treatment. A typing indicator is worthless a few seconds later, so the client sends 'typing' at most once every few seconds while the text changes — this scenario assumes three — only over the live socket, never stored, queued, retried or pushed; offline, it is dropped. The receiver shows it and expires it locally a few seconds after the last one, clearing it at once when a message from that person arrives, so a lost 'stopped' event cannot leave it stuck. A read receipt must eventually reach the sender, so it is durable, but it is **cumulative**: 'read up to sequence N' for the conversation, sent when the messages are on screen with the app in the foreground, debounced while scrolling, and never lower than the last one sent. Only the newest pending receipt per conversation is kept.
code
json · 4 lines[
{ "type": "typing", "conversationId": "match-8812" },
{ "type": "read", "conversationId": "match-8812", "upToSeq": 57 }
]go deeper
Remember that typing is temporary and can be dropped, while read receipts must eventually arrive, and that one 'read up to here' covers all earlier messages.
Explain throttling on the sender, local expiry on the receiver, cumulative read receipts, debouncing while scrolling, and keeping only the newest pending receipt.
Defend why typing never enters the offline queue or push, why receipts must never move backwards across devices, and why reading means visible in the foreground.
Weigh the traffic and privacy cost of these signals across the user base: an optional read-receipt setting, typing only in open chats, and how often presence may be refreshed.
## Two signals with opposite needs In a dating app's chat, the typing indicator and the read ticks both tell one person what the other is doing, but they differ in how long they stay true and what it costs to lose one. | Signal | Stays true for | If lost | Durable? | Rate control | Via push? | |---|---|---|---|---|---| | **Typing** | A few seconds | Nothing; the next one replaces it | No | Throttled on send, expired on receive | Never | | **Read receipt** | Until the next one supersedes it | The sender's ticks stay wrong | Yes, latest only | Cumulative and debounced | Only as part of normal sync | Designing both the same way fails in one direction or the other: a durable typing event replays stale "is typing…" after a reconnect, and a fire-and-forget read receipt leaves the sender's ticks stuck at delivered. ## Typing indicators **Sending side:** - Send `typing` when the user starts changing the text, then at most once every few seconds while they keep typing. This scenario assumes three seconds; the right figure is a product choice, not a standard. - Send it only over the live socket. If there is no connection, drop it — do not put it in the queue of offline writes, do not retry, do not ask the server to deliver it by push. - Optionally send `stopped` when the text box is cleared or the message is sent, as a hint. **Receiving side:** - Show the indicator on the first `typing` event. - **Expire it locally** a few seconds after the last one (this scenario assumes about six, comfortably longer than the send interval). - Clear it at once when a message from that person arrives, or when the socket drops. Local expiry is what makes the design safe. The `stopped` event can be lost — the sender's app may be backgrounded or lose signal mid-word — and a receiver that waited for it would show "is typing…" forever. ## Read receipts **What to send:** - One **cumulative** receipt per conversation: "read up to sequence N", where N is the highest sequence the user has actually seen. It covers every earlier message, including the sender's other messages, in one small update. - Send it when the messages are visible on screen with the app in the foreground — not when they are fetched, stored or shown in a notification. - Debounce it while the user scrolls through a backlog: thirty messages read in a burst produce one receipt for the last of them. - Never send a lower N than already sent; receipts only move forward. **How to keep it reliable without flooding:** 1. Store the pending receipt durably so it survives the app being closed. 2. Keep only the newest per conversation: a receipt for 57 replaces an unsent one for 52, because 57 says everything 52 did. 3. Send it with the next connection; if it was lost, the next receipt repairs the gap automatically, because it is cumulative. **On the sender's phone:** a "read up to 57" receipt marks every one of the sender's own messages with sequence 57 or below as read, never moving any of them backwards. ## Presence "Online" and "last seen" are related but different: the server typically derives them from connection heartbeats with a time-to-live, and decides how widely to share them. The client's part is rendering what the server says and not inventing presence — for example, it should stop showing "online" for the match once the server's status is stale rather than trusting the last value forever. ## What interviewers probe - "The sender lost signal mid-word — is the indicator stuck?" Not if the receiver expires it locally. - "The user scrolls through fifty unread messages — how many receipts?" One, cumulative. - "The read receipt was sent offline — is it lost?" No: it was stored, collapsed to the newest, and sent on reconnect. - "Should typing wake the match's phone?" Never; a stale typing push is worse than none. A strong answer separates the two signals by how long each stays true, then gives each the matching delivery rule.
- Why should the receiver's expiry be longer than the sender's typing interval?So a steady typist's indicator does not flicker off between refreshes. If the sender refreshes every three seconds and the receiver expires after six, one delayed refresh is absorbed; if expiry were shorter than the interval, the indicator would blink off and on while the person keeps typing.
- The match reads the chat on two devices; how should read receipts combine?Each device sends its own cumulative 'read up to N'; the server keeps the highest and relays it. Because receipts only move forward, a lower value from the slower device changes nothing, and the sender's ticks reflect the furthest point read anywhere.
- Queue typing events offline so the match sees them later.
- Keep the indicator until a 'stopped typing' event arrives.
- Send a separate read receipt for every message on screen.
- Send read receipts as soon as messages are fetched or stored.
- Deliver typing indicators through push when the match is offline.