The interview problem
Design a shared text editor for 100,000 simultaneously connected users. Users edit immediately, work offline for up to 30 days and reconnect without losing accepted edits. Support document permissions, version recovery and up to 50 concurrent editors per document. Explain what convergence does and does not guarantee.
Original system-design practice, not a reported company interview. Scale assumptions and examples are hypothetical. Technical references retrieved September 27, 2026.
Quick answer
A collaborative editor must converge document edits while keeping synchronization durable and authorized. CRDT updates can tolerate duplication and reordering when their model supports it, but access control and persistence remain separate responsibilities. Treat cursor presence as ephemeral state rather than durable document history.
1. Separate local response from durable acceptance
Local typing should update the editor immediately. “Saved on this device,” “accepted by the server” and “seen by collaborators” are different states. Persist offline operations locally before claiming device-level recovery, then acknowledge server acceptance only after durable storage under the chosen replication policy. A destroyed device can lose unsynchronized edits; the service cannot recover bytes it never received.
Scope the first version to plain text with cursor presence. Rich formatting, comments and embedded objects introduce additional merge semantics. Define a document deletion policy and a 30-day offline compatibility window. Revoking access prevents future authorized synchronization; it cannot erase a document someone already downloaded.
2. Work through a concurrent edit
Start with the text “cat,” represented by stable element identities C, A and T. Alice inserts the character “x,” with a new identity X, after C while offline. Bob deletes the element A. If both operations refer to identities instead of current numeric offsets, applying both should produce “cxt” under the chosen sequence semantics. Bob's deletion targets A, not whichever character happens to occupy offset one when his message arrives.
If Alice and Bob both insert after C, a sequence algorithm needs a deterministic ordering for concurrent insertions. Unique operation identities and a specified ordering rule can make replicas agree; receive order alone cannot. But agreement does not prove the result matches both authors' intentions. Concurrent multi-character edits can produce surprising text depending on the algorithm and grouping rules.
Choose a mature sequence CRDT implementation for this offline-first design, rather than inventing one tie-break rule and calling the algorithm complete. Operational transformation is another option, with transformation rules and history coordination that must be defended. A server-serialized overwrite is simpler but does not satisfy lossless merging of offline edits.
3. Separate durable document state from presence
The path is editor with local operation store → authenticated synchronization gateway → document partition → durable update log and snapshots. Gateways broadcast accepted updates to subscribed peers. Partition by document ID so most synchronization work stays within one owner group; use a routing directory and reconnect protocol when ownership changes.
Store document ID, generation, update ID, encoded update, principal attribution, acceptance sequence and schema/protocol version. The storage sequence supports replay and snapshot boundaries; it need not determine CRDT conflict resolution. Keep permissions in an authoritative service and validate them before accepting updates or returning document state. Do not trust a client-provided author field as authenticated identity.
Presence, selections and typing indicators use an ephemeral channel with expiry and rate limits. Losing a cursor packet is acceptable; losing an acknowledged text update is not. Anchor cursors to document identities through the editor integration so remote edits do not make raw offsets misleading.
A hot document can dominate fanout. Enforce the editor cap, bound queued bytes per connection and disconnect slow readers with a resynchronization instruction instead of buffering forever. View-only audiences can use a separately scalable broadcast path.
4. Make reconnect and acknowledgment explicit
On reconnect, authenticate, verify the document generation and permissions, and exchange synchronization state using the selected library's protocol. Fetch missing accepted updates and submit pending local updates. Stable IDs and idempotent application allow retry after a lost acknowledgment. The server must still deduplicate durable acceptance and audit accounting; an idempotent merge does not make every surrounding side effect idempotent.
Yjs documents update application as order-independent and idempotent, and provides state-vector-based difference exchange. Use that protocol rather than treating a state vector as a complete application authorization record. Library convergence assumes the necessary valid updates eventually arrive; it does not provide persistence, access checks or abuse limits.
For a server crash after append but before acknowledgment, retry finds the stored update and returns its accepted identity. For a crash before append, retry performs the append. For a disconnected peer, retain enough compatible state to recover or require a supported snapshot-based resync. Reject malformed or oversized updates before they consume unbounded memory, and validate any application-level structures introduced beyond plain text.
5. Estimate updates and fanout
Assume 20% of the 100,000 connected users are actively editing, each emitting two batched updates per second, with 200 bytes of encoded payload per update. Ingress is 40,000 updates/s or 8 MB/s. If each update has four other recipients on average, outgoing update payload is 32 MB/s. Headers, encryption, acknowledgments and presence add overhead.
At this sustained rate, raw update payload is 691.2 GB/day. Three storage copies require 2.0736 TB/day before indexes and metadata. This is an intentionally conservative continuous-load estimate, not a forecast that every user edits all day. Measure duty cycles and compression on real documents.
A document with all 50 editors producing two updates/s yields 100 incoming updates/s and 4,900 outgoing deliveries/s if every update goes to the other 49 editors. At 200 bytes, that is 0.98 MB/s of payload for one document. Small global averages can hide hot-document CPU and connection pressure.
Snapshots reduce replay work, but a current snapshot alone does not necessarily preserve the product's complete version-history promise. Price recoverable history separately from current-state storage and define retention before choosing compaction.
6. Compact without stranding offline users
Create a snapshot representing a known accepted-log boundary, store it durably with a checksum and compatible format version, then atomically publish its manifest. Readers load that snapshot and replay later updates. Delete obsolete log segments only after verifying recovery and retention requirements; never publish a pointer to an incomplete snapshot.
Merging encoded updates is not necessarily garbage collection of deleted content. Yjs explicitly distinguishes the two. Deleted identities and causal metadata may remain necessary to interpret an offline client's pending operations. Use the library's supported retention and synchronization behavior, with tests across the full offline window, rather than discarding every tombstone based on age alone.
For clients outside the compatibility window, preserve their local content for export or an explicit merge workflow. A new document generation can force a full resync, but blindly applying old operations to a new identity space is unsafe. Document deletion followed by recreation should not accidentally resurrect edits from the deleted generation.
Undo should create a meaningful compensating edit scoped to the user's action, not restore an entire old document snapshot over collaborators' work. Historical recovery can create a new branch or an explicitly authorized restore operation with visible consequences.
7. Defend permissions and failure behavior
A user edits offline after access is revoked. At reconnect, reject the write according to current policy; do not accept it simply because the client was authorized last week. Preserve a local draft or export option where product policy allows, and clearly separate rejected local work from accepted shared state. Permission invalidation must also stop subsequent content delivery on existing subscriptions. Define a revocation acknowledgment boundary: the service confirms revocation only after affected delivery paths enforce the new permission version or have been fenced. Already delivered content and bytes already in flight cannot be recalled.
A network partition can preserve local editing while preventing durable shared acknowledgment. If multiple server owners accept writes, CRDT merging can resolve compatible document operations, but permissions, deletion and billing still require their own consistency policy. Fencing ownership can simplify those surrounding decisions.
Test shuffled and duplicated update delivery, missing-update recovery, concurrent insert/delete, long offline histories, expired permissions, snapshot crashes and incompatible client versions. Assert convergence of accepted state and the intended user-visible semantics separately. A matching final hash cannot detect every confusing merge or unauthorized edit.
Foundation: explain why a numeric offset is an unstable edit target. Senior: recover a lost acknowledgment and justify snapshot boundaries. Staff: reconcile offline availability, revocation and bounded metadata retention.
Score 0–2 each for edit semantics, durable synchronization, authorization, capacity and offline recovery. Compare with chat delivery and file storage.
Budget cursor traffic separately from edits
In one room with 50 editors, assume each sends ten cursor updates per second, each with an 80-byte application payload, and each update goes to the other 49 editors. Server outbound payload is 50 × 10 × 80 × 49 = 1,960,000 bytes/second, or 1.96 MB/s in decimal units. Protocol overhead is additional.
Coalescing to two cursor updates per second per editor reduces that payload to 392,000 bytes/second: an 80% reduction. Prefer the newest position for each editor and expire it after a short presence TTL. During congestion, drop intermediate cursor positions before dropping durable edits.
Do not apply the same “latest wins” shortcut to arbitrary document updates: discarded edits may carry causal information required for convergence. Measure edit delivery separately from cursor smoothness, and account for hot-room fan-out beyond the site-wide average in the capacity calculator.
Sources and next steps
- A Conflict-Free Replicated JSON Datatype — foundational research on convergent replicated structures.
- Yjs document updates — update synchronization, state differences and the distinction between merging and garbage collection.
The architecture and examples are original. Convergence properties belong to a specified algorithm and valid execution model; they do not replace authorization or guarantee human intent preservation.
Continue your preparation
Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.