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's System Design interview questions cover 25 questions at difficulty 1–5 of 5.
  • Tarmac tracked 2,173 job postings asking for System Design in November 2026.
  • Roles asking for System Design advertise a median base salary of £86,000, across 642 job postings as of November 2026.
  • Tarmac last reviewed these System Design interview questions on 13 October 2026.

At a glance

Questions25
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 asynchronous database replication, the primary can report a write as successful to the client without waiting for any replica to receive it, so a write acknowledged before a primary failure may be missing from the replicas.#

Options

Show answer

True. Asynchronous replication lets the primary report a write as successful as soon as it commits locally, without waiting for any replica. If the primary fails before the change has been shipped, that acknowledged write may be absent from the replicas. This trade-off is why synchronous replication waits for replica acknowledgment, accepting higher latency to protect durability.

Why:

Asynchronous replication does not make the primary wait for replicas before answering the client. The primary commits locally, returns success, and ships the change afterward. If the primary crashes before the change reaches a replica, the client has already been told the write succeeded, yet the replica that gets promoted does not have it. Synchronous replication avoids this by holding the acknowledgment until a replica confirms, which is why it costs more write latency. The statement avoids naming any specific product's fallback or quorum behavior, so it holds across systems.

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.

A single standard Raft group (majority quorums, no weighted or flexible quorums) storing a shard of user posts has 5 replicas placed 2 in North America, 2 in Europe, and 1 in Asia. Answer three short parts. (1) What is the commit quorum size, and can a write be committed using only replicas in one region? (2) Name the Raft read technique in which the leader records its commit index and confirms it is still leader through a heartbeat round acknowledged by a quorum, so a linearizable read can be served without appending to the log. (3) To guarantee read-your-writes for a user across devices, what single per-user value should the system store after each of that user's writes, and what must a replica satisfy to serve that user's read?#

Show answer

(1) The quorum size is 3 of 5. The largest region holds only 2 replicas, so no write can be committed using one region alone; every commit needs at least one replica outside the leader's region. (2) ReadIndex: the leader records its commit index, confirms leadership with a quorum heartbeat round, waits until its applied index reaches that read index, then serves the read without writing to the log. (3) Store the log index of the user's latest committed write, per user in server-side session or account state so it works from any device. A replica may serve that user's read only if its applied index is at least the stored log index.

Why:

With 5 replicas a majority is 3, and the largest region holds 2, so under standard majority-quorum Raft every commit includes a replica from another region. The technique that confirms leadership via a quorum heartbeat without a log write is ReadIndex. For read-your-writes, the log index of the user's latest committed write is stored per user, and a replica may serve that user's read only once its applied index is at least that value, which works across devices unlike a fixed time window.

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 a tradeoff it genuinely incurs?#

Options

Show answer

Single-leader replication routes every write through one leader, so writers far from it pay cross-region network latency. Multi-leader replication accepts writes in several regions, which creates conflicting concurrent writes that must be resolved. Leaderless Dynamo-style systems tune consistency with read and write quorums, but concurrent writes can leave conflicting versions the application must reconcile.

Why:

The correct pairing names a real tradeoff for each topology. A single leader serializes all writes, so clients far from it pay the network round trip to reach it. Multi-leader setups accept writes in multiple regions locally, which lowers write latency but means concurrent updates to the same data conflict and need a resolution strategy such as last-writer-wins or CRDTs. Leaderless Dynamo-style systems tune consistency through read and write quorum sizes, but concurrent writes can produce conflicting versions that the client or application must reconcile. The other options each attach a property to the wrong topology (quorums to single-leader, a leader bottleneck to multi-leader or leaderless) or state a false guarantee (no conflicts, guaranteed latest value, linearizable multi-leader writes).

A ride-state record is replicated with Raft across five voting members, one in each of five regions (US East, US West, EU, India, Australia). A write is acknowledged to the client only after it is persisted on a quorum of members. In two to four sentences, explain why a quorum acknowledgment (rather than acknowledgment by the leader alone) is what lets a ride-state write survive the loss of any single region, and what the new leader after a failover is guaranteed to contain.#

Show answer

A write is acknowledged only after a quorum of three of five members has persisted it, so the committed entry exists in at least three regions. Losing any one region leaves four members, and any majority of five overlaps with the set that holds the committed entry. Raft's election rule lets only a candidate whose log is at least as up-to-date as a majority's win, so the new leader necessarily holds every committed ride-state entry. The leader alone could fail with its region before replicating, so its acknowledgment would not be durable.

Why:

The question asks for the reason a quorum acknowledgment makes ride-state writes durable across a single region loss, which is a determinate property of Raft rather than an open design choice. With five voters, a quorum is three, so a committed entry is stored in at least three regions. Any later majority must intersect that set in at least one member, and Raft's election restriction (a candidate must have an up-to-date log to win votes) ensures the elected leader contains every committed entry. A leader-only acknowledgment gives no such guarantee because the leader's region can fail before the entry reaches any other member.

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.

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.

A global document-editing SaaS runs active-active (multi-leader) asynchronous replication, with every region accepting writes to the same document. Two users in different regions edit the same paragraph while the regions cannot reach each other. Explain (1) how the system uses version vectors to decide whether the two versions are concurrent, and (2) why it must not resolve the conflict with last-writer-wins by wall-clock timestamp. Answer in 3-5 sentences.#

Show answer

Each document version carries a version vector with one counter per region; a region increments its own counter when it writes. Version A dominates version B if every counter in A is greater than or equal to the matching counter in B and at least one is strictly greater. If neither vector dominates the other, the two versions are concurrent, meaning neither write saw the other. Wall-clock last-writer-wins would pick one of the concurrent versions arbitrarily (clock skew makes the order meaningless) and silently discard the other edit, violating the no-silent-loss requirement. Instead, the system flags the pair as a conflict and either merges it with a CRDT for text edits or keeps both versions and surfaces them to the user.

Why:

The question is narrowed to a single, checkable mechanism so the answer is deterministic. A version vector holds one counter per region, and a version dominates another only when every counter is greater than or equal to the other's with at least one strictly greater. Two versions whose vectors are incomparable are concurrent, because neither write observed the other. Last-writer-wins by wall-clock time is unsafe here: clock skew makes the ordering arbitrary, and it silently drops one of two concurrent edits, violating the no-silent-loss requirement. The correct handling is to detect the conflict from the vectors and then merge it or surface both versions.

Related interview questions

Job market

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

Practise these until they stick

That's every question we hold on this topic, and the page marks what you pick. What it can't do is remember. A free account keeps every answer, and 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 answers per 30 days, each marked with written feedback

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.