The interview problem

Practice prompt

A fleet of 100 inventory-allocation workers transfers reservation credits over 400 directed logical channels. Design a diagnostic snapshot that checks conservation while transfers continue. Explain in-flight messages, worker restarts, incomplete captures and storage cost. Does this also provide a complete disaster-recovery protocol?

Original system-design practice, not a reported company interview. Workload and calculations are hypothetical. Technical reference: Chandy and Lamport, February 1985; retrieved September 27, 2026. Interview date not applicable.

1. Define what the snapshot must preserve

The captured state must account for credits held by workers and credits transferred but not yet applied by recipients. A receipt cannot appear without its corresponding send. A send whose receipt is outside the cut belongs in channel state. The goal is a consistent causal boundary, not a photograph taken everywhere at one wall-clock timestamp.

For this exercise, freeze the participant and channel topology for one snapshot epoch. Assume reliable FIFO logical delivery and serialized application events. Credit creation and expiry are disabled in the worked example. A production version must include the creation, expiry and external-input journals in its accounting boundary.

Define sending as the atomic balance decrement plus durable outbox append. Define receipt as the atomic balance increment plus durable deduplication progress. A network acknowledgment alone is neither of these application events. Retries retain the transfer ID and cannot create a second debit or credit.

2. Show why independent copies fail

Worker A begins with 70 credits and B with 30. A sends 20 to B. After A commits its send but before B applies it, their local balances are 50 and 30. Copying only these balances reports 80. The missing 20 are a channel obligation, not evidence that inventory disappeared.

A different unsafe cut copies A before the send and B after the receipt. It reports 70 + 50 = 120. This cut includes the effect at B without the cause at A. Adding whatever messages happen to be in a broker at some later time does not repair an arbitrary pair of local copies.

A useful interview answer must explain both missing in-flight work and a receipt without its send. Synchronized clocks alone do not make local checkpoint operations atomic with message processing.

3. Establish boundaries with ordered markers

The classic algorithm assumes reliable FIFO channels. A process records local state and sends a marker on each outgoing channel before subsequent application messages. Its first received marker triggers local recording if necessary; that marker's channel is recorded empty. On other incoming channels it records messages arriving after its local checkpoint until their markers arrive. Every participant must be reached, and markers must eventually be processed for completion. The result need not equal an actual simultaneous wall-clock state.

For our implementation, snapshot IDs separate epochs, and a local event loop orders checkpoint boundaries with application sends and receives. Sending markers through a faster control connection is unsafe unless an additional protocol preserves their position relative to application messages. A marker that overtakes an older transfer can close recording too early.

Keep marker handling idempotent per snapshot and logical channel. An initiator starts recording all incoming channels when it captures its own state. A participant that starts upon receiving a marker records the triggering channel as closed and records its remaining incoming channels until their markers arrive.

4. Trace one valid snapshot

Use bidirectional channels between A and B. The sequence below deliberately lets the transfer cross B's local checkpoint boundary.

EventSnapshot consequence
B initiates and records balance 30B begins recording A→B and sends its marker toward A
Before that marker reaches A, A sends transfer T = 20A's live balance becomes 50; T is enqueued toward B
A receives B's markerA records 50 and the B→A channel as empty; A enqueues its marker after T
B receives and applies TB's live balance becomes 50; its frozen balance stays 30; channel recording includes T
B receives A's markerB closes the A→B recording
recorded A balance       50
recorded B balance       30
recorded A→B transfer    20
recorded B→A transfers    0
                         ───
total                   100

Applying T to the frozen B state would produce 50, but then T must leave the reconstructed channel. Counting the updated balance and the original channel obligation together would double count it. Conservation is also not sufficient to prove each transfer correct: one lost transfer and an unrelated duplicate of the same size can cancel numerically. Reconcile individual transfer identities as well.

5. Separate capture from durable publication

coordinator: snapshot ID + topology epoch + fenced owner
        ↓
worker event loops: local checkpoint boundary + ordered markers
        ↓
immutable local state + incoming-channel records
        ↓
checksummed staging artifacts and completion receipts
        ↓
manifest validator → atomic publication of complete snapshot

These are proposed production extensions, not guarantees supplied by the original algorithm. The coordinator records the expected workers and channels before capture. Choose initiators whose directed reachability covers every participant; one initiator is insufficient if some workers cannot be reached from it. Isolated workers must initiate locally under the same snapshot ID. Each worker creates an immutable state handle at its local boundary, then uploads asynchronously. Copy-on-write or versioned state avoids holding an application lock for the entire upload, but pinned versions still consume resources.

Every artifact carries the snapshot ID, topology epoch, worker incarnation, schema version, checksum and relevant sequence boundaries. The coordinator publishes a manifest only after all required local and channel artifacts are durable and validated. Marker completion alone does not mean their bytes survived a crash.

Represent snapshot status explicitly: preparing, capturing, persisting, complete or aborted. Readers consume only complete manifests. Persist abort decisions and reject late completion receipts or markers for an aborted ID; a retry uses a new ID. A timeout produces an aborted attempt and diagnostics, not a smaller snapshot falsely labeled complete. Keep the previous verified snapshot available.

6. Account for queues at the application boundary

A real transfer may occupy a sender outbox, broker partition or receiver inbox before its application receipt. Define one logical channel spanning this path. A transfer ID must occupy exactly one accounting position in the captured model, even if physical retry copies exist in several buffers.

For example, treat the credit obligation as sent when its debit and outbox append commit, and as received when the recipient's credit and deduplication update commit. Channel records then represent the logical transfers between those two boundaries. Do not add raw broker contents to outbox contents and assume their sum is channel state.

The ordered-marker implementation must respect those boundaries through reconnects, retry queues and consumer prefetch. A broker partition offset does not automatically establish application processing order across multiple concurrent handlers. Serialize processing per logical channel, or implement an equivalent proven boundary protocol. If the transport remains unordered, use an appropriate different algorithm rather than pretending FIFO holds.

7. Calculate the capture and retention budget

Assume each worker has 2 GB of snapshot state. Across all channels, traffic is 100,000 messages per second at 500 bytes per message. Use decimal units and a hypothetical ten-second channel-recording interval.

local state = 100 × 2 GB = 200 GB
channel bytes = 100,000 × 500 × 10 = 500 MB
full artifact set = 200.5 GB

at aggregate upload throughput 2 GB/second:
minimum transfer time = 200.5 / 2 = 100.25 seconds

one full snapshot every 300 seconds:
average artifact ingress = 200.5 GB / 300 ≈ 668.33 MB/second
12 retained full snapshots = 2,406 GB = 2.406 TB

The ten seconds is an assumption, not a bound promised by the algorithm. At sixty seconds, recorded channel data becomes 3 GB under the same traffic rate. Some channels may finish earlier; use measured per-channel rate times recording duration for a more precise estimate. Serialization overhead, replication, retries and compression are excluded.

The 100.25 seconds is a byte-transfer lower bound, not end-to-end latency. Capture, contention, validation and storage stalls add time. A capture every five minutes also requires sustained throughput and enough temporary space for uncommitted artifacts. Initially allow one active capture; overlapping attempts can multiply pinned state and channel recording costs.

The fixed graph needs 400 marker sends per snapshot, excluding retries and control acknowledgments. Marker count can be small while data capture cost is large. Track the longest open channel, bytes pinned, upload backlog and age of the last complete snapshot.

8. Fail closed on incomplete boundaries

FailureRiskDesign response
Worker restarts during captureLocal state and channel logs come from different incarnationsResume only from persisted, proven boundaries; otherwise abort the epoch
Coordinator loses ownershipTwo owners publish conflicting manifestsDurable status and fenced publication with compare-and-set
Marker stalls behind trafficChannel recording grows without limitByte/time budgets, alerting and clean abort; do not silently truncate
Artifact upload failsLogical completion lacks durable dataRetry immutable uploads or abort; verify all artifacts before publication
Membership changesExpected channel set becomes ambiguousKeep the epoch topology fixed or abort and restart after reconfiguration
Old staged data expiresA published manifest loses dependenciesProtect committed references before cleaning aborted staging

Garbage collection must distinguish abandoned attempts from committed snapshots. A cleanup TTL cannot delete an artifact merely because its upload began long ago while publication is still racing. Coordinate reference protection with the manifest commit protocol.

9. Explain what recovery still requires

A diagnostic snapshot can establish a consistent modeled state without being a usable recovery package. Recovery needs compatible executables and schemas, durable input positions, replay rules and protection against repeating external effects. Sending an email or charging a payment after the cut cannot be undone merely by restoring an earlier worker balance.

Quiescing all workers and draining channels can simplify capture, at the cost of a coordinated availability interruption and a reliable drain protocol. Recording channel state permits continued work but introduces storage, ordering and replay complexity. Incremental snapshots can reduce bytes, but their dependency chain and retention correctness must be validated separately.

For this prompt, choose continued processing with ordered logical channels because availability matters and transfer IDs already support reconciliation. State clearly that changing the transport or adding external sinks changes the proof obligations.

Follow-up questions

  • Can we use the same timestamp everywhere? It does not establish atomic state/message boundaries or causal consistency by itself.
  • What if one worker is unreachable? Retain the previous complete snapshot, expose the missing participant and fail this attempt rather than asserting global consistency.
  • Can two initiators start together? Within one coordinated snapshot ID the protocol can support multiple initiators; separate IDs require separate recording state and resource budgets.
  • Does total balance prove correctness? No. Check transfer identities, uniqueness and sender/recipient agreement as well.
  • How would you test it? Enumerate short send/receive/marker schedules; inject crashes around state capture and publication; verify no published manifest omits required artifacts.

Self-review rubric

A strong answer defines application send and receipt events, accounts for channel state and explains why FIFO marker ordering matters. It traces a consistent cut and an inconsistent one, names the completion gate and checks storage arithmetic. An excellent answer addresses reconnects, prefetched messages, fixed membership, failed uploads and worker incarnations, while separating diagnostic consistency from external-effect recovery.

Sources and attribution

Retrieved September 27, 2026. The PDF upload path is not the publication date. Algorithm assumptions are attributed above; the reservation-credit scenario, implementation proposals, calculations and review questions are original practice. No company interview attribution is claimed.

Continue your preparation

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