Design a messaging service around three separate facts: the server accepted a message, a device received it, and a person read it.
Clarify this prompt before choosing components
Ask the highest-impact questions first, agree on priorities, and record the interviewer’s answers. If a detail is unspecified, state an assumption and explain which decision depends on it. The numbers in this worked lesson are exercise assumptions, not company facts.
| Ask the interviewer | Why the answer changes the design |
|---|---|
| One-to-one, groups, calls or all three? | Begin with text messaging; calls use a separate media plane. |
| What do sent, delivered and read mean, including multiple devices? | Server acceptance, device receipt and user read are distinct acknowledgments. |
| Offline retention, per-conversation order and group sizes? | Choose durable replay, cursor scope and fan-out ownership. |
| End-to-end encryption, new devices and group membership changes? | Clients own plaintext; key distribution, device revocation and historical access require explicit policy. |
Use the Interview Playbook for the shared 45-minute sequence and fresher, intermediate, senior and staff evidence. Start with one complete operation. Extend the answer with the failure/recovery traces below, then defend a workload-specific alternative and a measurable rollout. Scope and evidence matter more than a large component list.
WhatsApp: Understand the building blocks
Choose a mechanism because it satisfies a requirement. These explanations describe the exercise design, not undisclosed implementation choices at the named company.
WhatsApp: Quick vocabulary
| Term | Meaning and role in this exercise |
|---|---|
| API: Application Programming Interface | The contract for requests, responses and errors between components. An API route does not itself enforce every business invariant. |
| PK: Primary Key | The declared row identity in a database schema; it does not automatically enforce every cross-row business rule. |
WhatsApp: WebSocket
What it means: A protocol for bidirectional messages over a persistent connection after a handshake. It is a transport, not a durable message store.
Why this problem needs it: Active clients need low-latency bidirectional delivery.
How to use it: Authenticate the session, route incoming messages to their owner, and bound outgoing buffers. Reconnect using application message IDs and cursors.
Example in this design: Send and acknowledge m7 over a connection, then replay after its applied cursor on reconnect.
When it fits: Useful when both sides send frequent low-latency updates.
Alternative and limits: Polling is simpler at low update rates; Server-Sent Events fit one-way server updates. A new connection does not restore missed messages by itself.
WhatsApp: End-to-End Encryption (E2EE)
What it means: E2EE protects message content so only the intended endpoint key holders can decrypt it under the chosen key protocol. Transport TLS protects a connection instead.
Why this problem needs it: Privacy requirements may prohibit server access to message bodies.
How to use it: Define key/device identity, device addition, rotation and encrypted backup/recovery behavior; the server can route ciphertext while enforcing metadata permissions.
Example in this design: Route m7 as ciphertext; device enrollment and backup keys remain separate design work.
When it fits: Useful when the server should not read message bodies.
Alternative and limits: Server-side encryption may support server search/moderation but changes the privacy contract. E2EE does not hide all metadata or solve device/key recovery automatically.
WhatsApp: Idempotency key and stored operation result
What it means: Idempotency means replaying the same logical operation produces no additional business effect. A key identifies that operation under a defined scope.
Why this problem needs it: A reconnect must not create a second logical message.
How to use it: Atomically associate a request key and payload fingerprint with its effect and result. Return the stored result on replay; reject incompatible payload reuse.
Example in this design: Retry the original sender message ID instead of assigning another ID.
When it fits: Needed when a timeout can hide a successful commit or a queue can redeliver.
Alternative and limits: Unique business identities can enforce selected effects. A cache of recent requests alone may expire too early or race; local keys cannot control an uncooperative external provider.
WhatsApp: Snapshot, retained suffix and recovery cursor
What it means: A snapshot records state at a named revision; the retained suffix contains later changes; a cursor marks a declared consumed position.
Why this problem needs it: Offline devices need bounded history catch-up.
How to use it: Recover from one consistent snapshot/revision and replay the necessary suffix with stable identities. Reset explicitly when required history expired.
Example in this design: A cursor at applied sequence 50 requests later retained events, deduplicating overlap.
When it fits: Useful to bound replay and let disconnected clients catch up.
Alternative and limits: Full replay is simpler for tiny histories. A cursor beyond unapplied events can lose updates; two unrelated reads do not form one consistent snapshot.
Interview scope and guarantees
Send one-to-one messages, synchronize devices, retrieve offline history, and distinguish accepted, delivered, and read receipts. Agree group size and retention before adding groups. The transport may reconnect; durable message identity must survive it.
Capacity worksheet
Assume 10 million users send 50 messages/day: 500 million/day, about 5,787 writes/s average and 28,935/s peak at 5×. At 1 KB/message that is 500 GB/day raw before replicas and indexes. Ten million simultaneous connections at 10 KB of server state each require about 100 GB spread across gateway instances.
Concrete API contract
POST /conversations/{id}/messages {clientMessageId,ciphertext}
GET /conversations/{id}/messages?afterSequence=...
POST /receipts {messageId,deviceId,status}
WebSocket resume {conversationId,lastSequence}Data model and access paths
messages(conversation_id,sequence,message_id,ciphertext); PK(conversation_id,sequence)
client_keys(conversation_id,sender_id,client_message_id,request_hash,message_id); UNIQUE(conversation_id,sender_id,client_message_id)
device_cursors(user_id,device_id,conversation_id,last_delivered)
memberships(conversation_id,user_id,version)Evolve a solution and explain each change
Read the diagram
Persist before acknowledging / Store a conversation message and sender retry identity. / A socket acknowledgement alone does not mean durable acceptance.; Deliver across devices / Use per-device cursors and replay from the message log after reconnect. / Online push can be lost; receipt states can be conflated.; Separate state and content / Track accepted, delivered, and read receipts with bounded fanout and encrypted payloads. / Encrypted content does not remove metadata or membership risks.
Step 1: Persist before acknowledging
Store a conversation message and sender retry identity. A socket acknowledgement alone does not mean durable acceptance.
Step 2: Deliver across devices
Use per-device cursors and replay from the message log after reconnect. Online push can be lost; receipt states can be conflated.
Step 3: Separate state and content
Track accepted, delivered, and read receipts with bounded fanout and encrypted payloads. Encrypted content does not remove metadata or membership risks.
Responsibility overview
Read the diagram
Sender to Message API: send client message ID; Message API to Message log: append server sequence; Message log to Delivery worker: delivery intent; Delivery worker to Recipient: push wake-up; Recipient to Message API: fetch after cursor; Message API to Device cursors: device checkpoint
Worked end-to-end scenario
A sender transmits message m7, but the response disappears. Its retry uses the same client message ID, so the server returns the existing accepted sequence. Recipient phone P is offline; laptop L is online and receives a wake-up. Each device pulls after its own cursor. P reconnects later and retrieves m7 from durable history. A delivered receipt means a specified device acknowledged receipt; a read receipt requires a distinct user action and privacy policy. Neither should be synthesized from successful database insertion. Group membership changes must determine which message versions a device may fetch.
Why these access paths matter
Partition messages by conversation and order by server sequence with a stable identity. Deduplicate by sender and client message ID within the conversation. Store per-device checkpoints separately from message content. For very large groups, explain whether writes fan out recipient references or reads fetch a shared log; both approaches still enforce membership.
Build the baseline first
Read the diagram
Sender → message API → durable append and sequence; Delivery worker → recipient gateway → device; Offline device → history cursor → missing messages
- Sender → message API → durable append and sequence.
- Delivery worker → recipient gateway → device.
- Offline device → history cursor → missing messages.
Evolve the design under load
Read the diagram
Conversation partitions → independent append owners; Connection directory → regional gateway fleet; Media attachment → object storage → encrypted reference
- Conversation partitions → independent append owners.
- Connection directory → regional gateway fleet.
- Media attachment → object storage → encrypted reference.
Defend the hardest decision
Per-conversation sequence numbers express server order; device timestamps do not reliably do so. The server acknowledges acceptance after durable commit. Delivery means a specific device acknowledged the message; read receipts are a separate user action. On reconnect, replay after the durable device cursor and deduplicate by message ID. Exactly-once presentation is a client/storage property built over potentially repeated delivery.
Failure and recovery analysis
The gateway sends a message but crashes before receiving acknowledgement. Resend on reconnect; the device upserts by message ID. For a membership removal, ensure the authorization epoch used to distribute future messages is current. End-to-end encryption changes what servers can search or moderate; do not promise plaintext server search while also claiming the server cannot decrypt.
Security and privacy boundary
Authenticate devices and membership, rotate or revoke device sessions, and protect metadata as well as message bodies.
Interview follow-ups with reasoning
Question: What if two devices send concurrently?
Show answer and explanation
Answer: Order at the conversation authority and keep distinct client message IDs.
Question: How do large groups change cost?
Show answer and explanation
Answer: Bound fanout and consider per-group log reads with device cursors.
Question: How do you handle presence?
Show answer and explanation
Answer: Treat it as ephemeral and approximate, never as proof of delivery.
Operate and verify the design
Acceptance latency, per-device delivery lag, reconnect replay gaps and duplicate presentation.
Disconnect after message commit but before acknowledgement, then replay the same client message ID.
A second scenario to test transfer
Alice sends while Bob’s phone is connected and his laptop is offline. The server accepts once, routes to the phone, and retains mailbox history. Bob’s phone acknowledges sequence 81. The laptop later resumes after 74 and fetches 75 through 81. Alice’s interface can show delivery according to the product’s receipt rule without pretending every device has caught up.
Bob’s phone acknowledges a message. May the service delete it before Bob’s laptop reconnects?
Show answer and explanation
Answer: Only if the retention and synchronization contract allows that loss. Device progress is distinct. Keep recoverable history or an appropriate encrypted backup/snapshot mechanism for the supported offline horizon.
Compare alternatives
| State | What it proves | What it does not prove |
|---|---|---|
| Accepted | Server durable boundary met | Recipient is online |
| Delivered | Specified device acknowledged | Every device synchronized |
| Read | Read action under product rules | Permanent human comprehension |
A design-changing exercise
The sender sees a successful API response. Can the UI show read?
Show answer and explanation
Answer: No. Acceptance, delivery, and reading are separate events with different evidence and privacy semantics.
Design workshop: conversation order and device progress
Choose one-to-one messages, bounded groups, multiple devices and offline catch-up as core. Calls are excluded. Assume server acceptance under 200 ms in the conversation home region, online delivery within one second under healthy conditions and a 30-day offline history contract. Those latency targets do not override durable acceptance or authorization.
Retry identity is unique(conversation_id,sender_id,client_message_id). The same identity with changed encrypted content returns 409. A conversation owner allocates a server sequence and inserts the message, request mapping and delivery intent in one durable transaction. It acknowledges accepted only after that boundary. On failover, a higher owner epoch prevents the old process assigning more sequences; an in-memory counter restored below the log head is unsafe.
Read the diagram
Send client m7; encrypt payload before upload; Commit sequence 81; return accepted m7 -> 81; Push sequence 81; Ack device P through 81; Reconnect device L after sequence 74; Replay 75..81 subject to current history policy
Store device_cursors(conversation,recipient,device_id,delivered_seq,read_seq), keyed by all three identities. Monotonic max updates make duplicated receipts safe. In this scenario sender-visible delivered means at least one recipient device acknowledged; read means an eligible recipient device reported read. Another product can choose all devices, but cannot infer that from one device's receipt. A group needs per-recipient receipts or bounded aggregate counts with a clear meaning.
Read the diagram
State / Evidence / Retry behavior; Accepted / Message durable at assigned conversation sequence / Return same sequence; Delivered / Chosen recipient device acknowledges that sequence / Monotonic device cursor; Read / Authorized device sends read action / Never decrease read cursor; History expired / Requested cursor predates retained messages / Explicit reset or supported encrypted backup
For bounded groups, persist once and create recipient mailbox references asynchronously under unique(message,recipient). Offline mailbox history survives a failed socket push. A gateway session registry locates online devices; it is not the message authority. At 1,000 recipients, a group message can create 1,000 delivery references and far more device sends. Shard delivery by recipient and cap group size/admission rather than assume one append implies one delivery operation.
If end-to-end encryption is in scope, choose an established protocol implementation rather than inventing cryptography. Device registration publishes authenticated identity/prekey material; senders encrypt to authorized recipient devices, and device additions require identity verification and membership updates. A group membership change rotates the group encryption epoch under the chosen protocol. The server stores ciphertext and delivery metadata; it cannot offer ordinary plaintext server-side search under that same guarantee. Backup/recovery keys and trust on new device registration need a separate threat model.
Removal from a group changes admission and history authorization at a membership version. This scenario denies new events to removed members and does not claim to erase bytes already downloaded. Push workers recheck membership before sending protected payload. If historical access after removal is allowed, encode that distinct policy instead of using current membership alone.
Exercise: Phone acknowledges 81, laptop is at 74, and sequence 75 reaches the end of retention. May phone's receipt delete all message history?
Show answer and explanation
Answer: Not under the 30-day per-device catch-up contract. Device cursors differ. Retain supported history or provide an explicit reset/backup path after expiry; accepted, delivered and retained-for-all-devices are different guarantees.
Signal specifications are a reference for established encryption protocols, not permission to describe a toy key exchange as production-safe E2EE.
Requirement trace and verification
| Requirement | Implementing design block | Verification link |
|---|---|---|
| R1 — Complete the primary user journey within the stated scope. | P01–P04; P09–P10. | V1 — Exercise the successful journey and the excluded/boundary case stated in the scope. |
| R2 — Preserve the problem's authoritative data invariant under concurrency. | P05–P06; P11–P12; DD1. | V2 — Run the race/replay case below and assert the invariant at the durable authority. |
| R3 — Meet the declared scale and API behavior without unbounded work. | P05–P08; P13–P14; relevant overload deep dives. | V3 — Exercise the API errors/retry identity and recompute the workload assumption that drives partition or capacity. |
| R4 — Recover from the named failure without losing or duplicating the user-visible outcome. | P15–P16; deep dives; Operations contract. | V4 — Drop live delivery, reconnect from two devices, duplicate a send, and fail the connection server; durable history remains recoverable. |
Operational contract
| Area | Decision and signals |
|---|---|
| SLIs | Durable-accept latency; per-device delivery lag; reconnect gaps; duplicate presentation; gateway connection saturation. |
| Overload limits | Cap connections per gateway, offline retention, group fanout, replay page size, and media bandwidth. |
| Recovery | Recover from durable conversation sequence and per-device cursor; replay after gateway loss with dedupe. |
| Access controls | Authorize conversation membership per send/read; protect message content and device/session credentials. |
| Dominant cost | Long-lived connection capacity, media storage, and cross-region message delivery. |
Senior-level interviewer follow-ups
Question: A user has three devices with different connectivity. What does a delivery receipt mean?
Show answer and explanation
Answer: Track per-device delivery cursors and define whether the aggregate receipt means any device or all required devices. A server acceptance, device receipt, and human read are separate facts.
Question: A device reconnects after its cursor was compacted. How does it recover?
Show answer and explanation
Answer: Return a bounded resync or snapshot token and then replay from a retained sequence. Define the retention horizon and avoid silently treating a missing cursor as fully synchronized.
A 60-second design answer
I would assign each conversation an ordered sequence at its owner, persist messages before acknowledging acceptance, and keep per-device delivery cursors. Reconnect replays after the cursor or performs a bounded resync when history has expired. Receipts distinguish accepted, delivered, and read. End-to-end encryption remains a protocol boundary, while server metadata and retention still need privacy controls.
Related concepts to revisit
Technical references
Kafka processing and external-sink boundaries.
PostgreSQL transaction isolation and concurrent updates.
Follow one chat across two devices
Chat c7 stores ordered messages 40,41,42. Device D1 acknowledges 42; D2 is offline at 40. A lost pub/sub push does not delete durable message 42. D2 resumes after 40, receives 41,42 and advances its own cursor. D1's acknowledgement does not establish D2 delivered either message.
chat c7: durable sequence 40,41,42
D1 cursor=42; D2 cursor=40
D2 resume -> 41,42
duplicate 41 -> ignore by stable message identityRead the diagram
chat c7: durable sequence 40,41,42; D1 cursor=42; D2 cursor=40; D2 resume -> 41,42; duplicate 41 -> ignore by stable message identity
Connection routing/presence is short-lived state; offline history and message identity are durable. A gap or cursor older than the retained horizon produces an explicit resync/expired-history outcome. Multi-device delivery, group membership and encryption policy require their declared scope rather than assuming one user-level acknowledgement. Media uses authorized object versions and a separate readiness flow.
Show answer and explanation
Answer: A successful socket send is not proof of the application's acknowledgement. Heartbeats detect connection liveness but do not establish that every preceding chat sequence was applied.
Decision review: WhatsApp
WhatsApp: What it is
A messaging design accepts logical messages, orders them within the agreed scope, and synchronizes eligible devices after interruption.
WhatsApp: Why it is needed
Sender retries and overlapping live/replay delivery can duplicate observations; an offline device cannot be silently included in a synchronous success promise.
WhatsApp: When to use it
Use durable history and per-device progress for offline or multi-device behavior. Choose ordering per conversation or another declared scope.
WhatsApp: How to use it
Authorize current membership, persist a stable client-message identity and server sequence, then acknowledge the agreed acceptance boundary. A device resumes from applied progress and deduplicates repeated message identities.
WhatsApp: Compare an alternative
Waiting for every device acknowledgement gives a stronger completion promise but lets offline devices delay success. Separate accepted, delivered and read states when that fits the product.
WhatsApp: Worked decision exercise
The following inputs and policies are original exercise assumptions; they are not measurements or undisclosed company behavior.
Message m7 commits at conversation sequence 51, but the sender loses the reply. Retrying the same client ID returns m7/51. A device that applied through 50 receives 51 by replay and again on the live path; it shows one message.
Read the diagram
Client ID c7 commits as message m7, sequence 51; Lost reply: retry c7 returns m7/51; Replay and live overlap at 51: apply once; Advance applied cursor only after application
Can a device advance its cursor when it receives bytes but before applying the message?
Show answer and explanation
Answer: Not if that cursor promises applied progress. A crash would skip an unapplied event. Define the durable/applicable cursor, retain replay within its horizon, and refresh from an authorized snapshot when it is too old. Recheck membership on reconnect.
WhatsApp: Check the design
Track acceptance and device delivery separately, replay horizon, missing sequence ranges and membership-denial behavior. A server acknowledgement is not evidence every device displayed content.
Screenshot variant: Two-user chat before group scale
For the SDE-1 version, agree to text messages between two authenticated users, offline replay and per-conversation order; leave calls, global sharding and group encryption key management as separate extensions. Assume 10,000 users send 20 messages/day: about 2.3 messages/s average. One transactional store plus a connection gateway is enough for this exercise.
Use conversation(id, participant_a, participant_b), message(conversation_id, sequence, sender_id, client_message_id, body) and device_cursor(conversation_id, device_id, delivered_seq, read_seq). Enforce uniqueness on (sender_id, client_message_id) and allocate sequence under the conversation owner. POST /conversations/{id}/messages returns durable message identity; GET /messages?after=sequence replays; a WebSocket carries delivery notifications. Authorize membership on every operation.
A sender submits m9, the server commits sequence 42 and its acknowledgment is lost. Retrying m9 returns 42. An offline receiver reconnects after sequence 40 and replays 41-42; duplicates are discarded by message identity. Sent means server acceptance, delivered means a recipient device acknowledgment, and read means an explicit user/client read acknowledgment. A socket write is not proof of any of these business states.
Screenshot variant: Group membership and read-receipt compression
For SDE-2, add membership(conversation_id,user_id,joined_seq,left_seq,version) and per-user/device read cursors. Define whether a newly joined member can see history and whether receipts from departed members count. A monotonic update such as read_seq = greatest(read_seq, received_seq) handles reordered acknowledgments without moving read state backward. Never advance a cursor beyond a message the member is allowed to read.
A group with 1,000 members and 10,000 messages does not need ten million individual read rows if the contract is contiguous reads: 1,000 read watermarks represent who read each sequence. A user at watermark 75 has read messages through 75 under that contract. If users can selectively read arbitrary messages, a single watermark is insufficient and gaps must be represented. Coalesce cursor broadcasts to avoid quadratic receipt fanout.
At sequence 80, M leaves. A delayed read acknowledgment for 82 must be checked against membership history and the receipt contract. For multiple devices, specify whether the user watermark is the maximum of device cursors or a separate explicit user action. Limit per-connection buffers; slow recipients recover by replay instead of consuming unlimited gateway memory.
Show answer and explanation
Answer: A group message can be durably accepted while some devices remain offline. Store it once under conversation order, fan out references or delivery work, track independent cursors, and expose partial delivery honestly. The follow-up is to revoke membership during replay and verify that no unauthorized message body is returned.
Deep dive: replay and receipts belong to an authorized membership interval
Start with two authenticated users, text messages and one conversation authority. A connection gateway manages sockets; the message store owns durable acceptance and replay. Extend that baseline to groups only after defining order, membership, receipt meaning and bounded delivery. The product name is an interview prompt, not a claim about a company's implementation. End-to-end encryption/key distribution is a separate requirement: server authorization is necessary but does not itself implement encrypted group membership or key rotation.
Define acknowledgements before choosing a transport
| State shown to the sender | Evidence under this exercise | What it does not establish |
|---|---|---|
| Accepted | Message and publication intent committed under the conversation owner | A recipient device received it |
| Delivered to a device | Authenticated device acknowledgement for that message/range | Its owner opened or read the text |
| Read by a user | Explicit user/device read action under the declared contiguous-read policy | Every device read it or the person understood it |
WebSocket, polling and push notifications carry signals; none changes the evidence required for these states. A successful socket write may only fill a local buffer. A push-provider acknowledgement is not a chat read receipt. Offline recipients remain pending while the sender sees the strongest evidence actually available.
message(conversation_id, sequence, message_id, sender_id,
membership_epoch, client_message_id, payload_fingerprint, body)
UNIQUE(conversation_id, sender_id, membership_epoch, client_message_id)
membership(conversation_id, user_id, epoch, joined_seq, left_seq, active)
cursor(conversation_id, user_id, epoch, device_id, delivered_seq, read_seq)
outbox(event_id, conversation_id, sequence)One owner allocates monotonically increasing sequence numbers and commits the message, accepted result and outbox together. A retry after the response is lost resolves the same message ID/sequence; a different body under the same scoped key conflicts. Serialize membership changes with message admission so a stale gateway cannot authorize a new send after removal. An accepted historical operation may have a receipt, but returning its message body still requires the current read policy.
Treat reconnect as replay, not another send
A recipient has durably stored through sequence 40. Reconnect requests messages after 40 with a bounded page and a server-provided continuation. The server checks current access and the historical visibility interval before returning any body. Device storage and acknowledgement have their own crash boundary: if the client crashes before recording its cursor, replay repeats messages and the client deduplicates by message identity.
Keep the contract explicit when history was trimmed. If a cursor predates the retention floor, return a declared resync/history-unavailable result instead of silently claiming complete delivery. A last-seen timestamp is ambiguous when messages share timestamps or clocks change; the ordered sequence/continuation defines pagination. Partition independent conversations first; adding API nodes cannot increase a single hot conversation's serialized ownership capacity automatically.
Membership and receipt compression need compatible semantics
This exercise gives an epoch a half-open historical interval [joined_seq, left_seq), with an open upper end for an active epoch. A new member sees only messages from its join boundary; removal blocks new reads and receipt mutations even for old messages. Another product can permit historical access after departure, but must specify it explicitly. Rejoining creates a new epoch; a delayed old-epoch acknowledgement must not advance the new epoch's cursor or reveal later messages.
Read the diagram
M is active in epoch 4 through sequence 80 → Removal closes access before sequence 81 → M rejoins in epoch 5 from sequence 91 → Old epoch 4 read acknowledgement claims 95 → Reject old receipt; epoch 5 stays unchanged
A read watermark r means all readable messages in this epoch's interval through r were read under a contiguous-read contract. It is valid only after the receiver validates a genuine explicit read action, epoch, current authority and allowed range; clamp/reject requests beyond the committed visible head according to policy. Do not use max(read_seq, received_seq) to turn an unauthorized 95 into proof of a read. A user skipping arbitrary messages needs gaps/per-message receipts instead of claiming a contiguous prefix.
For multiple devices, define whether the user watermark is the maximum of valid device read prefixes within the same epoch. Taking the maximum can satisfy a user-level “read on any device” policy; it cannot prove every device has read it. Delivered and read cursors remain distinct, and delayed smaller updates cannot move either backward.
Bound fanout and recovery traffic
With 1,000 members and 10,000 messages, naive per-message/per-user read rows can reach ten million rows. A contiguous per-user watermark uses about 1,000 user rows, plus device state and retained membership intervals. This reduces storage, not the network cost of broadcasting every receipt to every member: 1,000 receipt updates sent to 1,000 recipients can still approach one million deliveries. Coalesce updates, publish bounded summaries or let authorized clients query the receipts they need. Label “read by 20 of 1,000” against a stated membership-at-send/current-membership policy.
Gateways enforce per-connection byte/count limits and a send deadline. When a slow device exceeds its buffer, disconnect or stop live delivery and require bounded replay from durable state. Do not retain an unbounded in-memory queue to preserve the illusion of a healthy socket. Separate message acceptance capacity from fanout work; monitor committed-to-device lag, oldest replay cursor, stale-epoch rejections and buffer pressure. Minimize body/recipient data in general telemetry.
Chat assessment: prove the meaning of each cursor
Question: The sender's message committed at sequence 42, but the acknowledgement was lost. Should the client reconnect and send it under a new message identity?
Show answer and explanation
Answer: Retry the same scoped client identity and fingerprint to resolve sequence 42. A new identity is a new message and can duplicate the user's action.
Question: M rejoins as epoch 5. An epoch 4 read acknowledgement arrives for sequence 95. Is taking the maximum safe?
Show answer and explanation
Answer: No. Validate the current epoch and allowed interval before any monotonic update. Reject the old acknowledgement; it cannot advance epoch 5 or establish access to later text.
Question: Is one watermark sufficient when a user reads message 50 but intentionally skips unread messages 41–49?
Show answer and explanation
Answer: Not if it means a contiguous read prefix. Represent gaps/per-message evidence or keep the watermark below the gap; do not mark unseen messages read implicitly.
Score one point for durable message/retry identity, replay/retention semantics, epoch-scoped authorization, honest receipt meaning and bounded fanout/backpressure. Then revoke membership during a paginated replay and explain where every new body disclosure is checked. Review Security and Tenant Isolation and Idempotency for the shared boundaries.
Shared foundation: Time, Ordering and Identifiers
Time, Ordering and Identifiers: Choose clock and identity semantics, trace causal ordering and preserve identifier uniqueness across rollback and restart. Work its failure history before extending this design.
Bob’s phone acknowledges a message. May the service delete it before Bob’s laptop reconnects?
Your design draft
Clarify assumptions, explain your approach, and test the difficult cases. Save your draft, then compare it with the study notes.
Self-review checklist
Self-guided practice. Automated AI feedback and code execution are not connected.