System Design interview questions: Replication

Reviewed by Mark Dickie · Last updated

9 questions on this page you can answer and see marked on the spot. Go to the first one

Replication is the process of copying and maintaining data across multiple nodes so a system survives individual node failures and serves reads from more than one location. For interviews, you need to explain the trade-off between synchronous and asynchronous replication, how replication lag affects consistency, and when to choose single-leader versus multi-leader topologies. You should also be comfortable with quorum reads and writes, log-based replication mechanics, and common conflict-resolution strategies.

What does a replication interview question test?

Interviewers want to see whether you can reason about the tension between write durability and read availability under latency constraints. A typical prompt asks you to design a database that stays available during a network partition, or to explain what happens when a follower falls behind the leader. The strongest answers name a specific consistency model (strong, eventual, causal) and connect it to a concrete replication configuration.

Single-leader vs. multi-leader vs. leaderless replication

StrategyWrite pathConflict handlingBest fit
Single-leaderAll writes go to one node; followers copy the logNo write conflicts; leader is the authorityMost OLTP workloads with a primary write region
Multi-leaderEach leader accepts writes; changes exchanged between leadersWrite conflicts possible; needs last-write-wins or custom mergeGeographically distributed writes across regions
LeaderlessAny node accepts writes; read repair or anti-entropy syncs replicasTunable via quorum (W + R > N)High-write-throughput systems that tolerate eventual consistency

Key concepts to prepare

  1. Synchronous vs. asynchronous replication: know how each affects write latency and the risk of data loss on leader failure.
  2. Replication lag: be able to describe read-after-write consistency and how to hide lag from users (session stickiness, read-your-writes).
  3. Quorum consistency: explain the W + R > N formula and what it guarantees when nodes fail.
  4. Log-based replication: understand how a write-ahead log or change data capture stream propagates changes to followers.
  5. Conflict resolution: compare timestamp ordering, application-level merges, and CRDTs for multi-leader setups.

What goes wrong in practice?

Replication lag is the most common real-world failure. When a follower falls seconds or minutes behind the leader, users see stale data or duplicate submissions. In interviews, naming these symptoms and tying them to a fix (read-from-leader for the user's own writes, monotonic reads via session affinity) shows operational depth beyond textbook definitions.

Key facts

  • Tarmac has 26 System Design interview questions on this topic, 25 of them on this page, at difficulty 1–5 of 5.
  • Tarmac tracked 3,763 job postings asking for System Design in September 2026.
  • Roles asking for System Design advertise a median base salary of US$180,347, across 1,250 job postings as of September 2026.
  • Tarmac last reviewed these System Design interview questions on 13 October 2026.

At a glance

Questions25 shown · 26 in the bank
Difficulty1–5 of 5
FormatsMultiple choice, Short answer, True / false, Fill in the blank, Flashcard, Design exercise

What you'll review

  1. replication
  2. cap consistency
  3. scalability

Practice questions

Try one before you open the answer. Pick an option and press Check; it's marked on the spot.

In a single-leader (primary–secondary) replication system, which nodes can accept write requests from clients?#

Options

Show answer

In single-leader (primary–secondary) replication, only the leader, also called the primary, accepts client write requests. The leader applies each write locally and then ships it to followers through the replication log. Followers serve reads and replay that log, but they do not accept writes directly, which prevents divergent copies and write conflicts.

Why:

In single-leader replication, the leader (primary) is the sole authority for writes. It applies a write locally and then forwards the change to followers through the replication log. If followers accepted direct writes, the copies would diverge without a conflict-resolution mechanism, which defeats the purpose of a single writer. Followers serve reads and stay current by replaying the leader's log, so being caught up does not grant write access.

In a single-leader (primary–secondary) replication system, what is the role of the follower (secondary) replica?#

Show answer

The follower holds a copy of the data by applying the replication log sent by the leader, and it can serve client read requests. Clients send writes to the leader, not to the follower, so the leader remains the single source of truth for write ordering.

Why:

The follower's core job is to maintain a copy of the data and keep it current by applying the replication log the leader ships to it. Because the follower has the data, it can serve read requests, which spreads load and improves read availability. Writes are not accepted directly from clients on a follower; they go to the leader, which orders them and is the single source of truth, and the follower then receives those changes through the log.

In synchronous database replication, the primary acknowledges a write to the client only after at least one replica has confirmed that it received the write.#

Options

Show answer

Synchronous replication means the primary waits for at least one replica to confirm it has received a write before reporting success to the client. This guarantees the write exists on a second node, improving durability, at the cost of higher write latency. Asynchronous replication does not wait and can lose acknowledged writes if the primary fails.

Why:

In synchronous replication the primary does not report a write as successful until the configured replica(s) acknowledge receipt of the data. Waiting for that acknowledgment is what gives stronger durability, since the write exists on a second node before the client is told it succeeded, and it is also why write latency rises. Asynchronous replication, by contrast, returns success immediately and can lose recently acknowledged writes if the primary fails before replication completes.

Complete the sentence. In _____ replication, the primary writes data locally and reports success to the client immediately, then propagates changes to replicas later. This reduces write latency but can leave the primary and replicas temporarily out of sync if the primary fails before replication completes.#

Show answer

Complete the sentence. In asynchronous replication, the primary writes data locally and reports success to the client immediately, then propagates changes to replicas later. This reduces write latency but can leave the primary and replicas temporarily out of sync if the primary fails before replication completes.

Why:

In asynchronous replication, the primary acknowledges a write as soon as it is applied locally and ships the change to replicas in the background. Because the client does not wait for replicas, write latency is low, but any writes not yet propagated are lost if the primary crashes, which creates a temporary inconsistency window between primary and replicas. Synchronous replication is the opposite: the primary waits for replica confirmation before acknowledging.

A write is committed on the leader at 10:00:00. The follower receives and applies that same write at 10:00:03. The 3-second delay between the leader's commit and the follower's visibility of the write is called _____.#

Show answer

A write is committed on the leader at 10:00:00. The follower receives and applies that same write at 10:00:03. The 3-second delay between the leader's commit and the follower's visibility of the write is called replication lag.

Why:

The gap between a write being committed on the leader and that same write becoming visible on a follower is called replication lag (also written replica lag). It arises inherently in asynchronous replication, where the leader acknowledges the write to the client before followers have applied it, so followers can briefly serve stale reads.

In a web application using single-leader asynchronous replication, a user submits a comment and immediately refreshes the page. The read request is routed to a follower replica, and the new comment does not appear. What consistency guarantee is violated, and what is one common application-level technique to prevent this?#

Show answer

This violates read-after-write (read-your-writes) consistency. The user's write went to the leader, but the read was served by a follower that had not yet received the replicated update because of replication lag. A common fix is to route the user's own reads to the leader for a short window after their write (for example, one minute), or to use session-based sticky routing so the user's reads go to the leader until the followers catch up.

Why:

The scenario is a textbook read-your-writes violation: the user's own write is not visible in their subsequent read because that read was served by a lagging asynchronous follower. The guarantee is named as read-after-write (read-your-writes) consistency. Because the write went to the leader and the read was served by a follower, the standard application-level remedy is to pin the same user's reads to the leader for a brief period after a write, or to use session-based sticky routing so that user sees their own writes. Either technique is accepted, since the question asks for one.

In single-leader replication, a slow or failed follower can block all writes system-wide when using _____ replication for all followers.#

Show answer

In single-leader replication, a slow or failed follower can block all writes system-wide when using synchronous replication for all followers.

Why:

With synchronous replication to all followers, the leader waits for every follower to acknowledge each write before confirming it to the client. If any follower is slow or down, the leader cannot complete the write, so writes across the system stall. Asynchronous replication avoids this because the leader does not wait for every follower's acknowledgment.

In a single-leader (primary-secondary) database replication configuration, what is the primary trade-off of configuring write replication to be synchronous rather than asynchronous?#

Options

Show answer

Synchronous replication increases write latency: the leader must wait for at least one follower to confirm the write before acknowledging it to the client. This guarantees durability on multiple nodes but adds a network round-trip to every write — the standard consistency-vs-latency trade-off compared with asynchronous replication, which acknowledges immediately but risks data loss if the leader fails.

Why:

With synchronous replication the leader blocks the client's write request until at least one follower has acknowledged persisting the change, which guarantees durability on multiple nodes but adds round-trip latency to every write — the classic consistency-vs-latency trade-off. The claim about zero lag across all followers is false: only the specifically-confirmed follower is caught up; other followers can still lag. The batching rationale for throughput is not the standard or primary trade-off, and the key effect is the added write-path latency. Read scalability is a property of adding replicas for reads, not of choosing synchronous replication; even synchronous replication to one follower does not make all followers instantaneously current for reads.

You offload reads to asynchronous read replicas. Right after a user updates their profile and is redirected to view it, they sometimes see the old data. Which approach fixes this read-your-writes problem with the least global cost?#

Options

Show answer

Route that one user's reads to the primary for a short window after their write. The symptom is replication lag — the async replica hasn't applied the write yet — so pinning just that user to the primary gives them read-your-writes consistency while everyone else keeps the replica offload. Sending all reads to the primary or forcing synchronous replication is far more expensive than the problem warrants.

Why:

The symptom is replication lag: an async replica hasn't applied the user's write yet. Pinning that specific user's reads to the primary for a brief post-write window gives them read-your-writes consistency while everyone else still benefits from replica offload — minimal global cost. Sending all reads to the primary throws away the scaling benefit the replicas existed to provide. Forcing fully synchronous replication makes every write wait on every replica, hurting write latency and availability far beyond what this problem warrants. A fixed client-side delay is a guess — lag is variable, so it is both unreliable and a poor user experience.

With asynchronous primary-replica replication, a client can write to the primary and immediately read a stale value from a replica.#

Options

Show answer

True. Asynchronous replication acknowledges the write on the primary before the change has propagated, so a read routed to a lagging replica can miss the just-written value — the classic read-your-writes anomaly. Mitigations include pinning that user's reads to the primary for a short window after a write, using a synchronous or quorum write, or tracking replication lag.

Why:

Asynchronous replication acknowledges the write on the primary before the change has propagated, so a read routed to a lagging replica can miss the just-written value — the classic read-your-writes anomaly. Mitigations include routing a user's reads to the primary for a short window after a write, using a synchronous/quorum write, or tracking replication lag and pinning sticky reads.

What problem do read replicas solve, and what is their key limitation?#

Show answer

Read replicas offload read traffic from the primary database by streaming changes asynchronously to one or more followers. They let you scale read throughput linearly (add a replica, add read capacity) without scaling the primary write path. The key limitation is replication lag: replicas trail the primary by milliseconds to seconds, so reads against a replica may return stale data — a write followed immediately by a read-your-own-write to a different replica can miss the write. Applications must direct writes (and reads-after-writes) to the primary and route read-heavy, stale-tolerant queries (reports, timelines, analytics) to replicas.

Why:

Read replicas are the first lever most teams pull when their database becomes read-bound. The correct mental model is: replicas are eventually consistent copies, not synchronised mirrors. Whether the lag is tolerable depends on the read's freshness requirement — user profile reads often tolerate seconds of lag; financial balances usually cannot.

In a _____ replication topology all writes go to one node that propagates changes to read-only followers, while a _____ topology accepts writes on more than one node and must resolve write conflicts.#

Show answer

In a single-leader replication topology all writes go to one node that propagates changes to read-only followers, while a multi-leader topology accepts writes on more than one node and must resolve write conflicts.

Why:

Single-leader replication is the default in most relational databases: one writable primary, many read replicas, simple conflict handling because writes are serialised at the leader. Multi-leader replication accepts writes in multiple regions/nodes for lower write latency and partition tolerance, but introduces the hard problem of conflict resolution (last-write-wins, CRDTs, or application merge). Leaderless quorum systems are a third model used by Dynamo-style stores.

In a single-leader (primary/secondary) replication system using asynchronous followers, which statement about read-after-write (read-your-writes) consistency is correct?#

Options

Show answer

Read-after-write consistency in a single-leader system with asynchronous followers is achieved by routing a user's reads to the leader for a short window after their write, or by reading from a follower only after it has replicated past that write. Ordered log application alone does not guarantee it, because followers can lag behind the leader and serve stale data.

Why:

With asynchronous followers, the leader acknowledges a write before followers have applied it, so a follower can lag. A read from a lagging follower right after the user's own write may miss that write. The statement about routing that user's reads to the leader for a bounded window, or reading from a follower only once its replication position has passed the client's last write, describes the two standard fixes and is correct. Applying the log in order does not mean reads are up to date, asynchronous replication itself gives no such guarantee, and sending more reads to lagging followers makes stale reads more likely, not less.

A quorum-based replicated key-value store has N=5 replicas and is configured with W=2 (a write succeeds once 2 replicas acknowledge it) and R=2 (a read consults 2 replicas and returns the newest version it sees). A client's write has been acknowledged to the client, and afterwards a different client reads the same key and receives the old value because its 2 replicas never received the write. Which guarantee does this configuration fail to provide?#

Options

Show answer

Linearizability (strong consistency) is the guarantee this configuration breaks. With W=2, R=2 and N=5, R + W = 4 does not exceed N, so the write and read quorums can be disjoint and a read after an acknowledged write may return a stale value. Setting R + W > N restores quorum overlap.

Why:

For quorum reads to always see the latest acknowledged write, the read and write quorums must overlap, which requires R + W > N. Here R + W = 4 is not greater than N = 5, so the 2-replica write set and the 2-replica read set can be disjoint (for example, writes land on replicas 0 and 1 while the read hits replicas 2 and 3). A read that starts after an acknowledged write can then return a stale value, which violates linearizability (strong consistency). The other options concern properties unrelated to this scenario: idempotency is about repeated request effects, multi-key transaction isolation involves transactions spanning several keys, and leader election safety applies to leader-based protocols, while this store is leaderless. Raising R or W so that R + W > N (for example R=3, W=3) restores quorum overlap.

In an asynchronous single-leader (primary–replica) replication system, all writes go to the leader but reads may be served by any replica. After a user submits a write, a subsequent read of that same data from a replica may return stale data because the replica hasn't yet caught up. Which technique restores read-after-write (read-your-writes) consistency for the writing user while still allowing most reads to be served asynchronously from replicas?#

Options

Show answer

Read-your-writes consistency is restored by routing the writing user's reads to the leader, or to a replica known to have applied their write, for a short window after the write. Other users' reads can still use any replica, so most read traffic keeps the scaling and latency benefits of asynchronous replication.

Why:

This is the classic read-your-writes pattern. The user who performed the write is directed to the leader, or to a replica confirmed to have applied that write, for a brief session window, so their own reads cannot observe stale data. All other reads still benefit from asynchronous replica reads. Switching to multi-leader replication does not address the problem and adds write-conflict complexity. Adding more replicas does not guarantee a replica has caught up with a specific write, since lag can still exist. Serving every read from the leader restores consistency but abandons the replica scaling the question requires.

In an asynchronous single-leader replication system, the time delay between a write being committed on the leader and that write becoming visible on a follower replica is called _____. When this delay causes a client that has already read a newer value to subsequently read an older value from a different replica, appearing to go backward in time, the violated consistency guarantee is called _____ consistency.#

Show answer

In an asynchronous single-leader replication system, the time delay between a write being committed on the leader and that write becoming visible on a follower replica is called replication lag. When this delay causes a client that has already read a newer value to subsequently read an older value from a different replica, appearing to go backward in time, the violated consistency guarantee is called monotonic reads consistency.

Why:

Replication lag is the standard term for the delay between a write being committed on the leader and becoming visible on a follower. When this lag causes a client that previously read newer data to later read older data from a different replica, appearing to go backward in time, the violated guarantee is monotonic reads consistency. This is distinct from read-after-write (read-your-writes) consistency, which concerns a client seeing its own most recent write, from eventual consistency, which the system still provides, and from linearizability, which is a stronger system-wide ordering guarantee.

You are designing the data layer for a social media application with 50 million users spread across North America, Europe, and Asia. The workload is read-heavy (approximately 100:1 read-to-write ratio). Two requirements are non-negotiable: (1) users must see their own posts immediately after publishing (read-your-writes), and (2) the system must survive a full data-center outage in any single region with no loss of already-committed posts. Design the replication strategy for the core user-post data store. Specify the replication topology, how reads and writes are routed, how you handle a leader or replica failure, and how you address replication lag for the read-your-writes requirement.#

Show answer

Shard users by user_id across N shards, and make each shard an independent 5-replica Raft group spread 2/2/1 across North America, Europe, and Asia. Prefer placing each shard's leader in the user's home region using leader priority or leadership transfer, which reduces write latency but is not guaranteed by Raft alone. A write is acknowledged only after a majority (at least 3 of 5) of replicas durably persist it. Any single-region outage removes at most 2 replicas, so 3 survive and can elect a new leader through Raft; because every committed entry sits on a majority, any elected leader holds all committed writes, so none are lost. Replica failure is absorbed by the remaining majority, and the failed replica catches up through log replication when it returns. Read-your-writes is handled by routing the publishing user's own reads to the shard leader for a fixed grace window (for example 30 seconds) after their last write. After the window, timeline and third-party reads go to the nearest replica whose log is within a configured lag threshold of the leader, and lagging replicas are removed from the read pool until they catch up. Users who relocate keep their data on the home-region shard, accepting higher write latency, and a background job can migrate permanently relocated users with an asynchronous copy followed by a single cutover.

Why:

This is an open design question with no single key, so it stays a short answer graded by keywords and the sample answer. The reference design uses one Raft group per shard with five replicas placed 2/2/1 across the three regions and a majority quorum of three. That placement means any single-region outage removes at most two replicas, leaving a majority, and because committed entries live on a majority, any newly elected leader has every committed write. Leader placement in the home region is a preference that must be configured through leader priority or leadership transfer, since Raft itself does not pin leaders. Read-your-writes is met by a fixed grace window that routes the publishing user's reads to the leader, while lag thresholds govern which replicas serve later reads, so the two mechanisms cover different read paths and do not conflict.

You are designing the replication subsystem for a globally distributed transactional database. Data is sharded across 20 partitions. Each partition has one leader that receives all writes for its key range and replicates a write-ahead log to followers deployed in three regions (US-East, EU-West, AP-South), one follower per region per partition (N=3 replicas per partition). Requirements: (1) A write must be durable in at least 2 regions before the client is acknowledged as committed (RPO = 0 for committed writes). (2) 95% of read traffic may be served from the geographically nearest follower (eventual consistency is acceptable), but a read-your-writes guarantee must hold for the writing user's own session. (3) If a region hosting the leader fails, a follower must be promoted within 30 seconds with zero loss of committed transactions, and split-brain must be impossible. Design the replication architecture and specify: (a) the replication protocol and the durability quorum (W, R, N), (b) how read-your-writes session consistency is enforced when reads go to a local follower, (c) the failover procedure including the mechanism that prevents split-brain, and (d) how replication lag is monitored and bounded.#

Show answer

Each partition runs single-leader, log-based replication (a Raft-style consensus log) with N=3, one replica per region. (a) Protocol and quorums: the leader appends each write to its WAL and sends the entry to both followers. A write is acknowledged as committed only after a majority of the replicas, the leader plus one follower (W=2 of N=3), have durably flushed it, so the committed write lives in two regions and survives the loss of any single region. Reads that tolerate staleness use R=1 from the nearest follower. (b) Read-your-writes: every commit response returns the LSN of the entry it produced, and the client session stores the highest LSN it has seen as a session token. A session-bound read is served by a local follower only if that follower's applied LSN is at least the session token; otherwise the read waits briefly for the follower to catch up or is routed to the leader. (c) Failover: heartbeats detect leader loss within about a second. Surviving replicas run a Raft-style election in which a candidate needs votes from a majority (2 of 3). Each leadership term carries a monotonically increasing epoch (fencing token); followers reject any append from a lower epoch, and a leader can commit only with acknowledgements from a majority within its own term, so a stale or partitioned old leader cannot commit or be accepted by followers. The winner is the candidate with the most up-to-date log (highest committed LSN), so no committed transaction is lost, and promotion fits within 30 seconds. (d) Lag monitoring: continuously track, per follower, the difference between the leader's committed LSN and the follower's applied LSN, along with the time lag. Alert when lag exceeds a threshold (e.g., 5 seconds). A lagging follower is removed from the synchronous acknowledgement set until it recovers. If too few replicas remain to form W=2, writes block rather than commit with fewer than two regions, and session reads on a lagging follower are rerouted to the leader, which bounds user-visible staleness.

Why:

This is an open design problem with no single option set, so it stays a SHORT_ANSWER graded against the sample answer and keywords. The strong answer names a majority-quorum protocol with W=2 of N=3 for durability across two regions, plus R=1 for nearest-follower reads. It enforces read-your-writes with LSN session tokens checked against the follower's applied LSN. It prevents split-brain with majority-vote elections and monotonically increasing fencing epochs, and it bounds lag with per-follower LSN and time-lag monitoring that removes lagging followers from the synchronous set and reroutes session reads to the leader.

Which option correctly pairs each replication topology (single-leader, multi-leader, leaderless Dynamo-style) with its key tradeoff?#

Options

Show answer

Single-leader replication gives linearizable writes, but every write must travel to the one leader, adding cross-region latency. Multi-leader replication lowers local write latency but needs conflict resolution and loses linearizability. Leaderless Dynamo-style systems offer tunable quorum consistency but require reconciling concurrent writes.

Why:

Single-leader replication buys linearizable writes by routing every write through one leader, so writes from distant regions pay cross-region latency. Multi-leader replication lets each region accept writes locally, cutting write latency, but concurrent writes to the same data conflict and must be resolved (for example with last-writer-wins or CRDTs), and it cannot provide linearizability. Leaderless Dynamo-style systems have no leader bottleneck and offer tunable consistency through read and write quorums, but concurrent writes must be reconciled by the client or application, and stale reads are possible when R+W is not greater than N. The option pairing each topology with exactly these tradeoffs is the only correct one; the others swap in properties that belong to a different topology or are simply false.

You are designing the data replication layer for a globally distributed ride-sharing platform operating across 5 regions (US East, US West, EU, India, Australia). The workload is roughly 99% reads (ride-status lookups, nearby-driver geospatial queries) and 1% writes (ride creation, ride-state transitions, driver-location pings). Writes originate from all 5 regions. P99 read latency must stay under 100 ms in every region, and the system must tolerate the loss of any single region without data loss for ride-state records. Design the replication strategy: topology, consistency guarantees per data category, conflict handling for concurrent writes, and failover.#

Show answer

I would use a tiered replication topology: a cross-region Raft consensus group with five voting members, one per region, for ride-state records, and asynchronous local streaming for driver-location telemetry. Each committed ride-state write must be acknowledged by a quorum of three of five members before the client sees success, so every committed record is durable in at least three regions and survives the loss of any single region. Local replicas serve ride-status lookups and nearby-driver queries, so reads stay within the region and meet the 100 ms P99 target; these local reads are eventually consistent, and any read that must be linearizable (for example final fare settlement) is routed through the Raft leader or served as a quorum read, accepting cross-region latency for that operation only. Telemetry uses plain asynchronous replication with no follower acknowledgment and last-writer-wins on timestamps, which is acceptable because a slightly stale position is still useful and telemetry carries no no-data-loss requirement. For conflicts, ride-state transitions are never merged: the Raft leader serializes all writes to a ride in log order, assigns a monotonic per-ride sequence number, and rejects any transition that violates the state machine (for example completed back to in_progress) before commit. For failover, when the leader's region fails, the surviving members detect the heartbeat timeout and run a Raft election in which only a member with an up-to-date log (higher last log term, then longer log) can win; because a committed entry exists on a quorum, the new leader is guaranteed to hold every committed ride-state record. A leader epoch (Raft term) acts as a fencing token attached to every write, so a partitioned old leader cannot commit conflicting entries. Client writes that were in flight when the region died are retried using idempotent, ride-id-keyed operations, and any write acknowledged to a client was already committed by quorum and therefore survives.

Why:

The question asks for an open design of a replication strategy covering topology, per-category consistency, conflict handling, and failover, so it is a short-answer question graded against its key concepts rather than a single fixed answer. The no-data-loss requirement for ride-state forces synchronous quorum replication through a consensus group spanning all five regions, so a single-region failure still leaves a majority that can elect a leader holding every committed entry. Local reads from non-leader replicas are necessarily eventually consistent, so any answer that claims both low-latency local reads and linearizable reads from those same replicas is internally contradictory; linearizable reads must go through the leader or a quorum read. Telemetry can use cheaper asynchronous replication with last-writer-wins because it tolerates staleness and does not carry the no-data-loss requirement. Ride-state conflicts are prevented by leader-serialized log order and state-machine validation rather than merged after the fact, and a leader epoch fences out a stale leader after a partition.

Design a file storage & sync service (think Dropbox / Google Drive): users store files in the cloud and keep them in sync across multiple devices.#

Show answer

Requirements. Beyond upload/download, the product is sync: a change on one device must propagate to the others, efficiently. 'Efficiently' means delta sync — never re-send an unchanged file. We must handle conflicts (two offline edits) without data loss and keep version history. Metadata ops (browse folders) are latency-sensitive; bulk byte transfer is throughput-bound.

Chunking & dedup. Files are split into content-hashed chunks (~4 MB; a chunk's id is the hash of its bytes). Editing one paragraph of a 1 GB file changes only the chunk(s) covering it, so the client uploads just those — a few MB, not a GB. Because chunks are content-addressed, identical chunks (same file shared by many users, or unchanged blocks across versions) are stored once — large dedup savings.

Block vs metadata split. Chunk bytes go to an object store (S3-style): content-addressed, effectively infinite, optimised for large immutable blobs — this holds the exabytes. The metadata DB holds the file→chunk-list mapping, the folder tree, ownership, and version history — small records with fast point/range reads to meet the <100 ms browse budget. The two layers have opposite access patterns, so they're separate systems.

Sync protocol & conflicts. Each device keeps a local view and learns of remote changes via a notification service (long-poll/push): 'your namespace changed past version V'. The client then pulls the metadata diff since its last-known version and downloads only the new chunks. Concurrent offline edits are detected by version: the second writer's base version is stale, so rather than overwrite, the system keeps both as a conflict copy (or merges where it safely can) and surfaces it — never a silent loss.

Consistency. Per file/namespace there's a monotonic version; metadata operations are ordered by it so all devices converge on the same state. Upload is commit-after-chunks: the client first writes all chunks to the object store, then flips the metadata pointer to the new chunk list. A half-uploaded file's pointer never goes live, so a reader never sees a file referencing chunks that aren't fully stored.

Scaling. The metadata DB shards by user_id (a user's files and folder tree stay together). The object store scales horizontally on its own. Sync notifications fan out to each of a user's devices. Dedup + delta sync are the multipliers — they cut both stored bytes and transferred bytes by large factors, which is what makes exabyte-scale storage and 5,800 ops/sec affordable.

Why:

A file sync service is defined by two structural decisions. First, content-addressed chunking: splitting files into ~4 MB hash-named blocks gives you delta sync (edit one paragraph of a 1 GB file → only the changed chunk transfers) and deduplication (identical chunks stored once) for free. Second, the block/metadata split: chunk bytes live in an object store built for huge immutable blobs and exabyte scale, while the file→chunk mapping and folder tree live in a separate, fast metadata DB — they have opposite access patterns. Correctness rests on commit-after-chunks ordering (flip the metadata pointer only after all chunks are durably stored) and version-based conflict handling that keeps a conflict copy rather than silently dropping one of two concurrent offline edits.

A fast-growing marketplace's product catalog read service has hit a wall: a single primary database serving every product-page and search-result read is saturating, page loads are slowing, and a sale event nearly took it down. Design how to scale this read-heavy service to handle an order-of-magnitude more traffic without melting the database.#

Show answer

Requirements & freshness. The workload is wildly read-heavy (~6,000:1 at peak) and global, with a p99 < 150 ms budget everywhere. The unlock is freshness tolerance: most catalog fields (title, description, images) can be seconds stale, while price/availability must propagate fast and be correct at checkout. That split is what lets me cache and replicate aggressively for the bulk of reads while treating the few critical fields specially.

Caching. A multi-tier cache fronts the read path: a small in-process cache on each app server, a shared distributed cache (Redis) behind it, and a CDN/edge cache for whole responses where possible. Reads are cache-aside: check cache → on miss, read the store, populate cache with a TTL. Writes update the store and invalidate/refresh the affected keys. With sensible TTLs this absorbs the overwhelming majority of the 30M reads/sec so the database barely sees them.

Replication. The single primary can't serve reads at this scale, so I add read replicas: all writes go to the primary, reads fan out across replicas (and mostly never reach them thanks to cache). This removes the read load from the primary, which now only handles the ~5K writes/sec. The catch is replication lag — a read replica may briefly trail the primary.

Consistency. I run eventual consistency for general catalog reads, with staleness bounded by cache TTL and replica lag — fine for browsing. For correctness-critical reads (the price/availability shown at checkout), I read from the primary (or a freshly-revalidated cache entry) so a customer never buys at a stale price. This is a deliberate CAP/freshness trade-off per field, not one global setting.

Hot keys & thundering herd. A flash-sale item that's 40% of reads would crush whichever single node holds its cache entry, so I spread the hot key: replicate it across multiple cache nodes / serve it from many edge locations / pin it in every app server's local cache — turning one hotspot into many. For the stampede when a hot entry expires and thousands miss at once, I use request coalescing (single-flight) so only one request recomputes while others wait, plus staggered/jittered TTLs and serve-stale-while-revalidate so an expiry never lets a herd through to the database.

Multi-region & bottleneck. Globally, I put edge caches and regional read replicas on each continent so reads are served near the user within the 150 ms budget; the primary stays in one region (writes are rare). The dominant bottleneck is the single write primary plus cache misses on hot keys — scaled by adding replicas and edge capacity, the hot-key and herd mitigations above, and, only if writes themselves outgrow one primary, sharding the catalog by product id. A read-your-writes need (seller edits then reloads) is met by routing that session's reads to the primary or a sticky/fresh replica.

Why:

Scaling a read-heavy service is the canonical caching + replication problem, and the lever that makes it tractable is a precise freshness stance: because most catalog fields tolerate a few seconds of staleness, you can absorb the overwhelming bulk of reads in a multi-tier cache (in-process → Redis → CDN edge) and fan the rare misses across read replicas, leaving the single write primary to handle only the sparse writes. The consistency answer is deliberately per-field — eventual consistency for browsing, but the price/availability shown at checkout is read fresh (primary or revalidated) so no one buys at a stale price (a real CAP trade-off, not a global toggle). The two failure modes that distinguish a strong answer are the hot key (a flash-sale item on one cache node — spread it across nodes/edge/local caches) and the thundering herd / cache stampede on expiry (request coalescing / single-flight + jittered TTLs + serve-stale-while-revalidate). Globally, edge caches and regional replicas meet the latency budget, and read-your-writes is handled by routing a writer's own reads to the primary.

Design the data replication layer for a global financial payments platform processing 50K transactions/sec across five regions (US-East, US-West, EU-West, AP-Southeast, AP-Northeast). Each transaction mutates account balances and must never be lost or double-applied. The business imposes three hard constraints: (1) reads of an account's balance from the account's home region must be linearizable; (2) writes must be accepted in any region within 500ms p99; and (3) the system must survive network partitions with no data loss and no divergent replicas. These three constraints are in tension — your design must resolve it explicitly. Specify the replication topology, quorum configuration, failover and split-brain strategy, the write path for non-home-region writes, and the mechanism that guarantees no transaction is applied twice.#

Show answer

Resolve the tension by giving up a single global write path rather than weakening the guarantees. Topology: shard accounts by a home region assigned at registration. Each shard is an independent Raft consensus group with 3 replicas placed in 3 different regions, with its leader in the home region, so the system is N independent single-leader problems instead of one global multi-leader problem. Quorum: a write commits once a majority (2 of 3) has persisted it in the Raft log, so one replica or one region can fail without losing committed data. Linearizable home-region balance reads are served by the leader only after it confirms it still holds leadership (lease read or ReadIndex, which requires a majority heartbeat), so no separate R=2 read quorum is needed for correctness. Failover and split-brain: when the leader is lost, a new leader is elected by majority; each leader carries a monotonically increasing term (fencing token), and followers reject entries from older terms, so a partitioned minority cannot commit and at most one leader exists per term. Non-home-region writes: the request is forwarded to the home-region leader and committed there; cross-continent round trips plus a majority commit can exceed 500ms p99, so constraint (2) is explicitly relaxed for remote-region writes and stated as a trade-off, while home-region writes stay within the SLA. Optimistic local acceptance with asynchronous reconciliation is rejected because it breaks linearizability and risks divergence under partition. Exactly-once application: every client transaction carries a client-generated unique request id; the state machine stores a durable dedup table keyed by request id, updated in the same log entry as the balance change, so a retried request either is rejected as a duplicate or returns the originally stored result. Log entries are applied in strict log index order on every replica, and re-applying an already-applied index is a no-op, so replays after recovery cannot double-apply money movement.

Why:

This is a staff-level design question because the three constraints conflict: linearizable reads need one authoritative copy per account, multi-region write acceptance tempts multi-leader replication (which breaks linearizability), and partition tolerance forbids silent loss or divergence. The resolution is to shard by account home region and give each shard a single Raft leader in that region, with majority commit across three regions so that partitions cause unavailability for minority sides rather than divergence. Linearizable home reads come from a leader that verifies its leadership, and term-based fencing stops a stale leader from committing. Non-home writes must travel to the home leader, so their latency cannot honestly meet the 500ms p99 target across continents; the answer must say this explicitly rather than hide it. Exactly-once application comes from a request-id dedup table written atomically with the balance change in the replicated log, because log-index dedup alone does not stop a client retry from being appended as a new entry.

In a Raft-based replicated log with 5 nodes, the current leader becomes network-partitioned from all other 4 nodes but continues to accept client writes from its own locally-connected clients. The remaining 4 nodes elect a new leader. When the partition heals, what happens to the writes accepted by the old leader, and what prevents the old leader from corrupting the log?#

Show answer

The old leader is in a minority partition (1 of 5 nodes) and cannot commit any writes because it lacks a majority quorum (3 of 5). It may append entries to its local log, but those entries stay uncommitted. When the partition heals, the old leader sees a higher term from the majority-elected new leader and reverts to follower. Its uncommitted entries conflict with the new leader's log and are truncated and overwritten through Raft's log-repair mechanism. The term number acts as a fencing token: followers reject AppendEntries RPCs carrying a stale term, and the old leader can never gather the majority acknowledgments it would need to commit. No committed data is lost; only the old leader's uncommitted entries are discarded.

Why:

Raft guarantees safety under network partitions via term-based leader election and majority quorums. The old leader, isolated in a 1-of-5 partition, cannot reach the majority (3 of 5) needed to commit any entry, so it may buffer writes but cannot mark them committed. Meanwhile the 4-node majority partition elects a new leader with a higher term. When the partition heals, the old leader encounters the higher term in an RPC and steps down to follower. Its uncommitted entries conflict with the new leader's log and are truncated and replaced. The monotonically increasing term works as a fencing token: stale-term requests are rejected, and the old leader cannot commit without a majority. This is why committed entries are never lost and the log never diverges.

A distributed storage system uses Raft consensus for replication across 5 nodes (1 leader + 4 followers). The leader replicates writes synchronously and only acknowledges a write to the client after the entry is committed, meaning it is replicated and persisted on a majority of the nodes (3, including the leader). The leader crashes immediately after sending the acknowledgment, before replicating the entry to the remaining 2 followers. After a new leader is elected, is the acknowledged write guaranteed to still be present in the new leader's log? Name the specific Raft safety property that ensures this and briefly explain the mechanism.#

Show answer

Yes. The write is guaranteed to be present in the new leader's log because of Raft's Leader Completeness property, which states that any entry committed in a given term appears in the logs of all leaders of later terms. The mechanism is the election restriction: a voter grants its vote only to a candidate whose log is at least as up-to-date as its own, comparing the last entry's term first and then log length, and a candidate needs votes from a majority to win. The committed entry sits on 3 of 5 nodes, and any electing majority of 3 must overlap that set in at least one node. That overlapping voter holds the entry and therefore refuses any candidate that lacks it, so the winning leader must already contain the committed write. The acknowledged write cannot be lost by the leader crash.

Why:

With N = 5 a majority is 3 nodes. The acknowledged entry was committed on 3 nodes (the leader and 2 followers) before the leader crashed. Raft's Leader Completeness property guarantees that any committed entry appears in the log of every future leader. This is enforced by the election restriction: a voter only grants its vote to a candidate whose log is at least as up-to-date as its own (last entry term first, then length), and a candidate needs a majority of votes. Any electing majority of 3 must overlap the 3 nodes holding the entry in at least one node; that node refuses any candidate missing the entry, so the winning leader must contain it. The write therefore survives the crash.

Related interview questions

Job market

See system-design salaries and hiring demand from live job postings.

The other 1 question

This page shows 25 and marks what you pick. That's as far as a page can go. A free account opens the other 1 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 marked answers per 30 days · written feedback on the paid plan

Interview booked? Practise the job ad instead

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.