The interview problem

Practice prompt

Design durable history for an AI conversation product. Users reopen conversations across devices, edit earlier prompts, regenerate answers and delete entire conversations. Support ten million daily active users while preserving branches and preventing a delayed generation from resurrecting deleted content. Real-time token transport is outside scope.

Original system-design practice with engineering inspiration, not a reported OpenAI interview or a description of OpenAI's conversation schema. All workload figures are hypothetical. Source retrieved September 27, 2026.

1. Define the history users expect

A conversation has an owner or tenant, an access policy, a lifecycle state and one or more branches. A branch is a path through message nodes, not a mutable text transcript. Editing an earlier prompt creates a new node with the same parent as the original prompt; regenerating an answer creates another child of the relevant prompt.

Assume shared conversations are read-only in this version. Multiple devices belonging to the owner can append, but conflicting branch-head updates must be explicit. Durable acknowledgement means a committed history record; a token visible in a streaming UI may still be provisional.

Require read-your-writes for the writer, stable pagination for a chosen branch snapshot and access denial for reads authorized after a confirmed conversation deletion. Already delivered content cannot be recalled; an in-flight response authorized before deletion may complete unless a stronger cancellation protocol is implemented. Physical removal from every derived store is an asynchronous process with a separately reported completion state.

2. Store nodes and branch heads separately

Use conversation metadata keyed by tenant and conversation ID, message nodes keyed by conversation and node ID, and branch records containing head node ID and revision. Nodes contain parent ID, role, content reference, creation time and status. Parent links are immutable; only lifecycle transitions such as pending to complete are controlled mutations.

Keep small message bodies in the database initially and large attachments in object storage. Content references carry integrity metadata and ownership. Conversation-level deletion becomes easier if attachment ownership is exclusive; cross-conversation deduplication requires reference accounting and complicates erasure.

Keep all writes for one conversation on one logical shard so append and head updates can share a transaction. Hash conversation IDs for distribution and include tenant checks on every lookup. A separate per-owner conversation-list index supports navigation; it need not be the authority for access or deletion.

3. Make retries and races visible

An append request includes a client idempotency key, expected branch revision, parent node and content hash. In one transaction, verify authorization and active lifecycle, create the node, conditionally advance the branch head and record the idempotency result. Validate that the parent belongs to the same conversation and is the expected branch head for an ordinary append; only an explicit fork operation can select an earlier ancestor. Reusing a key with a different payload returns a conflict.

If two devices both read revision 12, only one advances it to 13. The other receives a conflict and can refresh or intentionally create a sibling branch. Silently changing its parent would alter the conversation context used by the model.

For generation, first commit a pending assistant node and job identity. The worker writes its output to an attempt-specific location, then conditionally finalizes the node against the expected generation and conversation lifecycle. A retry cannot replace an already completed answer with a different sample. Orphaned attempt objects are collected later. Deletion cleanup must also fence or expire outstanding object-write capabilities and sweep late attempt uploads, so a worker cannot recreate retained data after the first cleanup pass.

Do not update the main history row for every token. Buffer streaming state separately and checkpoint at a bounded interval if resumability requires it. On interruption, distinguish a partial answer from a complete answer and let the user retry explicitly.

4. Page through a fixed branch

A pagination cursor binds the tenant, conversation, chosen head node, last returned position and format version. Sign it or store it server-side to prevent tampering. New nodes appended after the first page do not change the chosen head snapshot.

Walking parent pointers works for short histories but can create one database operation per message. Maintain bounded ancestry blocks or a branch-path projection for efficient page reads. Version the projection and fall back to authoritative nodes if it is behind; never silently combine two different branch paths.

Replicas and caches serve ordinary reads. After an append, carry a commit position or revision requirement so the next read waits for an adequate replica or routes to the writer. A cache entry includes tenant, conversation and branch snapshot. Cache hits still require a current authorization/deletion decision. For the stated deletion contract, this check uses a strongly consistent authority; an asynchronously invalidated cache alone is insufficient.

5. Size writes and history retention

Assume ten million daily active users create twenty stored nodes each day, counting both user and assistant messages. That is 200 million nodes/day, about 2,315 nodes/second on average. A tenfold peak is roughly 23,150 nodes/second. This does not include token-stream events.

At an average 2 KB per node including metadata, new payload is 400 GB/day. A ninety-day retained window is 36 TB, or 108 TB with three full copies, before indexes, backups and attachments. Branches share immutable ancestor nodes rather than duplicating full transcripts.

If half the nodes are assistant answers averaging 500 streamed tokens, persisting each token separately would create 50 billion token writes/day, about 579,000/second on average. The comparison explains why durable message storage and streaming delivery deserve separate paths; actual checkpoint cost depends on the chosen recovery promise.

Partition load tests by conversation size and tenant, not only aggregate throughput. A single huge conversation can make ancestry scans expensive even when total write rate is healthy. Bound page sizes, attachment sizes and traversal work.

6. Fence deletion before asynchronous cleanup

Delete begins with an authoritative tombstone and lifecycle version increment. The transaction denies future reads and appends, revokes sharing and emits a durable cleanup task. A generation worker carrying the old version cannot finalize its pending node after this point.

Workers remove message content, objects, caches, search documents, embeddings and other derived copies. Each consumer handles retries idempotently and records progress. A stale search result must still pass the authoritative lifecycle check before returning content. Previously issued long-lived object links undermine immediate denial, so use an access gateway or accept and clearly define a bounded revocation delay.

Backups follow their own retention and restore procedure. Restore must reapply deletion tombstones before serving restored data. Do not advertise immediate physical erasure when backup expiry is delayed. Keep only the minimal deletion evidence needed to prevent resurrection, under the agreed retention policy.

7. Isolate expensive workloads and verify recovery

Exports, search indexing and migrations should not consume the same unbounded query budget as opening a recent conversation. Rate-limit backfills, bound connection pools and coalesce cache misses. A cache failure must trigger controlled degradation rather than a stampede that saturates every database replica.

Test acknowledged-write survival under failover, idempotent retries after ambiguous timeouts, stale-replica reads, branch conflicts and delete-during-generation. The storage replication policy determines which failures can preserve acknowledged writes; a failover label alone is not a durability guarantee.

Follow-ups: How would collaborative editing change the concurrency model? How do you export one branch consistently? Can two conversations share attachments safely? What happens when deletion and cache refill race?

Score 0–2 each for branch semantics, transactional writes, snapshot reads, lifecycle fencing and workload/failure analysis.

Sources and next steps

The published engineering account motivates operational questions; it does not establish the schema or deletion protocol proposed here. The branching model, calculations and failure scenarios are original. Compare transport concerns in designing a chat system.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.