Skip to content
About
Main content

Scenarios

Longer problems, like those in senior system design interviews. A strong answer estimates with numbers first, names the mechanism, then recommends a fix and says what it costs.

Try each one before you open the answer.
1A cluster's leader froze for 9 seconds, and you want faster failover. A teammate proposes a 500 ms failure-detection timeout. Decide.Show the answer

Estimate

Pauses and network spikes of hundreds of milliseconds are common, so a 500 ms would cause frequent false suspicions and constant changes of .

What it costs

Each election costs availability. If writes carry , it does not cost correctness.

Recommend

An adaptive detector (phi-accrual style) whose threshold sits above of normal delays; fix the 9-second pause itself, for example by tuning garbage collection; and keep the rule independent of any timeout.

Read moreSafety and livenessFailure detectionLeader election and epochs

2A lock service with a 5-second TTL still allowed two writers at the same time. Diagnose and fix.Show the answer

Diagnose

The holder paused past the expiry, the lock was granted to someone else, and the first holder then woke and wrote, still believing it held the lock.

Fix

A : each grant comes with an increasing number, and the storage layer rejects writes carrying a lower number than one it has already seen. Expiry based on clocks can never be a safety mechanism on its own.

Cost

The storage must be able to check the token; a plain object store may need conditional writes.

Read moreLocks, leases and fences

3You must grow a 3-node metadata cluster to 5 nodes with no downtime. How?Show the answer

Procedure

Add one node, wait until it has caught up and the new configuration has committed, then add the second.

Why

Going from 3 to 5 in one step can create two majorities that do not overlap: 2 of the old 3 and 3 of the new 5.

Alternative

, where decisions temporarily need majorities of both the old and the new configuration.

Read moreMembership and reconfiguration

4The product team wants two data centres with automatic failover between them. What do you tell them?Show the answer

Explain

Two sites cannot distinguish a dead peer from a broken link between them, so automatic failover risks both sites promoting themselves: .

Options

Put a small witness, a member that stores no data, in a third , so a majority of three survives the loss of any one site. Or accept manual failover.

Cost

An extra location, and cross-site round trips on every decision.

Read moreSplit brain

5Adding nodes to a storage cluster means moving 12 TB, and the disks are 80% full. Plan the move.Show the answer

Estimate

At a throttle of 100 MB/s: 12,000,000 MB ÷ 100 MB/s = 120,000 s, about 33 hours.

Protocol

Copy, catch up, cut over, so the data stays readable throughout. Delete the source copy only after the routing map has flipped.

Check

Peak disk use on the sources, since data exists twice during the move, which matters at 80% full. Throttle to protect foreground latency.

Read moreResharding: the map is harder than the bytesThe movement protocol

6A page load fans out to 50 services, and its p99 latency is 8 times worse than any single service's. Fix it.Show the answer

Estimate

of page loads include at least one service's p99 event.

Options, by currency

  • Wasted work: at p95, capped at 5% extra requests; check the to confirm the slowness belongs to attempts.
  • Weakened semantics: return for approximate parts such as counters, if the page can tolerate a missing input.
  • Waiting: wait for the parts that must be exact.

Do not rely on

to fix the tail. And check that choosing large shards, good for fan-out, does not make recovery slow.

Read moreScatter-gatherHedgingNarrow the fan-out

7During a brownout, retries added at every layer of the stack made the outage worse. Redesign the retry behaviour.Show the answer

Estimate

Five layers with three retries each make up to per user action.

Redesign

  • Retry at one layer only: the one closest to the failure that can judge whether a retry is safe.
  • A token-bucket at the client, about 10% of recent successes.
  • passed along every call, so abandoned work stops.
  • operations, with and a deduplication window longer than the longest retry.

Trade-off

Some legitimate retries are refused during a partial outage. Backoff with jitter is a separate, complementary mechanism.

Read moreRetry budgetsRPC: idempotency and deadlines

8A team stores a fact for every file in the consensus cluster, and that cluster is now both the throughput ceiling and a source of outages. What is wrong?Show the answer

Diagnose

It breaks the rule that control-plane load must grow with changes, not requests, and probably the rule that the must stay off the data path.

Fix

Move bulk facts out (into manifests or data-plane metadata) and keep only small, rarely changing facts in consensus: membership, leadership, the map. Let the keep working on its last known map if the control plane is down, and protect against stale configuration with fencing.

Also

Name the hidden dependency, and add an alarm and a regular drill for losing the control plane.

Read moreControl plane and data planeAgreement and dissemination

9Choose a shard key for an orders database that serves checkout (single-order transactions), customer order-history pages, and a finance team's daily revenue-by-product report.Show the answer

The rule

Keep the common transaction and the common query inside one shard.

Choose

Checkout and history are customer-centric, so shard by customer_id: orders, addresses and payments sit together, with no cross-shard transactions.

The report

Revenue by product touches every shard, and a query across all shards is as slow as the slowest: with 100 shards each slow 1% of the time, of such queries hit a slow one. Do not run it on the OLTP shards; feed an analytical store, partitioned by product and date, through CDC.

Room to grow

Use 1,024 or more logical shards mapped onto physical nodes, so adding nodes moves logical shards and never changes the key mapping.

Risks

A very large customer (key skew) needs isolation, and changing the shard key later is a migration.

Read moreThe shard keyLogical and physical shards