CAP Theorem & Consistency interview questions

Reviewed by Mark Dickie · Last updated

The CAP theorem is a result from distributed systems theory stating that a distributed data store can provide at most two of three guarantees at once: consistency, availability, and partition tolerance. For interview purposes, the practical takeaway is that during a network partition you must choose between serving stale reads (availability) or rejecting requests until the partition heals (consistency). Most real-world systems pick AP or CP explicitly per subsystem rather than treating the whole architecture as one choice.

Examiners expect you to name the three properties precisely, explain why partition tolerance is non-negotiable in a distributed setting, and reason about consistency levels (strong, eventual, causal, read-your-writes) in concrete scenarios like a social feed or a payment ledger. They also look for whether you can map a consistency requirement to a coordination mechanism such as quorum reads and writes, leader election, or vector clocks.

What does a CAP-theorem interview question test?

The core skill is not reciting the theorem but defending a trade-off. You will be given a scenario (a shopping cart, a multi-region cache, a distributed counter) and asked what happens when a partition occurs. A strong answer identifies which operations can still complete correctly, which must block or error, and what the user-visible consequence is.

PropertyDefinitionWhat you give up
ConsistencyEvery read sees the most recent write or an errorAvailability during a partition
AvailabilityEvery request receives a non-error response (not necessarily the newest data)Strong consistency during a partition
Partition toleranceThe system continues to operate despite dropped or delayed messages between nodesNothing — you cannot opt out in a real network

How should I reason about consistency levels in an interview?

Beyond the binary CP/AP split, interviews often probe where on the consistency spectrum a system sits:

  1. Define the operation's correctness contract first: is a stale read acceptable for this call path?
  2. Pick a consistency model that satisfies that contract: strong for a bank balance, eventual for a view counter, read-your-writes for a user's own profile update.
  3. Choose a coordination mechanism that delivers that model at the latency and throughput your scale demands.
  4. State the failure mode explicitly: what the user sees when a node is unreachable, a quorum cannot be reached, or a conflict is detected.

What are common consistency trade-off scenarios asked in system design rounds?

Frequent prompts include designing a multi-region key-value store, a collaborative document editor, or a ticket-booking service. In each, the interviewer wants to see you connect the consistency requirement to a concrete technique:

ScenarioLikely consistency choiceCoordination technique
Multi-region user profileRead-your-writes or eventualSticky sessions, quorum reads (R + W > N)
Collaborative text editorCausal consistencyVector clocks or operation transforms
Ticket inventory counterStrong (linearizable)Single leader, serializable transactions, or CRDTs with merge rules
Social media feedEventualAsync replication, last-write-wins per post

When you answer, tie the choice back to the CAP triangle and to a measurable cost — extra round-trips, lower write throughput, or higher p99 latency — so the trade-off is visible rather than hand-waved.

Key facts

  • Tarmac has 14 System Design interview questions on this topic, 10 of them on this page, at difficulty 2–5 of 5.
  • Tarmac tracked 4,937 job postings asking for System Design in August 2026.
  • Roles asking for System Design advertise a median base salary of US$182,500, across 971 job postings as of August 2026.
  • Tarmac last reviewed these System Design interview questions on 31 August 2026.

At a glance

Questions10 shown · 14 in the bank
Difficulty2–5 of 5
FormatsMultiple choice, True / false, Multiple answer, Ordering, Short answer, Design exercise

What you'll review

  1. cap consistency
  2. rate limiting

Practice questions

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

System Design/sd-data/cap-consistency

According to the CAP theorem, a distributed system can guarantee at most two of the following three properties simultaneously. If a network partition occurs and you must keep all nodes available (responding to requests), which property must you sacrifice?#

Options

Show answer

When a network partition occurs and availability is prioritized, Consistency (C) must be sacrificed. The CAP theorem says you can only guarantee two of C, A, and P at once. Keeping all nodes available during a partition means some nodes may return stale data, violating the guarantee that every read reflects the most recent write.

Why:

CAP theorem states that during a network partition (P), a system must choose between Consistency and Availability. If you decide to keep all nodes available (A + P), nodes that are cut off may serve stale data, so you lose strong Consistency. Systems like DynamoDB and Cassandra make this choice (AP), while systems like HBase and traditional RDBMS clusters favor Consistency (CP) by refusing to serve requests from isolated nodes.

System Design/sd-data/cap-consistency

True or False: In an AP (Available + Partition-tolerant) distributed system like Apache Cassandra, a client can always read the most up-to-date value immediately after a successful write, regardless of which node it reads from.#

Options

Show answer

False. An AP system like Cassandra does NOT guarantee that every read immediately reflects the latest write. AP systems trade away strong consistency for availability during partitions, meaning different replicas may temporarily hold different versions of data. A read from a replica that hasn't yet received the latest write will return stale data — this is called eventual consistency.

Why:

AP systems sacrifice strong consistency in favour of availability during partitions. In Cassandra, writes are acknowledged once a configurable quorum of replicas responds, but other replicas may still be propagating the update. A client reading from a replica that hasn't yet received the write will see stale data. Cassandra offers 'eventual consistency' — the data will converge, but not necessarily instantly. To get the latest value you must use quorum reads, which is a consistency-vs-latency trade-off, not a guarantee of always-current reads.

System Design/sd-data/cap-consistency

A distributed key-value store must handle network partitions. It currently guarantees strong consistency (every read returns the most recent write) and availability (every request receives a response). According to the CAP theorem, which of the following best describes what must happen when a network partition occurs?#

Options

Show answer

When a network partition occurs, the system must sacrifice either strong consistency or availability — it cannot maintain both. The CAP theorem is a hard theoretical bound: since partitions cannot be prevented in distributed networks, the system designer must choose between a CP design (reject requests to stay consistent) or an AP design (serve potentially stale data to stay available). There is no middle ground during an active partition.

Why:

The CAP theorem states that a distributed system can guarantee at most two of Consistency, Availability, and Partition Tolerance simultaneously. In practice, network partitions are unavoidable in distributed systems, so partition tolerance is non-negotiable. When a partition occurs, the system must choose: either refuse some requests (sacrifice availability to maintain consistency, as in CP systems like ZooKeeper) or allow potentially stale responses (sacrifice strong consistency to remain available, as in AP systems like Cassandra). There is no timeout-based escape hatch — CAP is a hard theorem, not a performance bound.

System Design/sd-data/cap-consistency

Which of the following consistency models are weaker than linearizability (strong consistency) and are commonly chosen to improve availability or performance in distributed systems? Select all that apply.#

Options

Pick every one that applies.

Show answer

Eventual consistency, read-your-writes consistency, and monotonic read consistency are all weaker than linearizability. Eventual consistency allows temporary divergence between replicas; read-your-writes and monotonic read are session guarantees that relax real-time global ordering to gain availability. Strict serializability is at least as strong as linearizability, and two-phase commit is a commit protocol, not a consistency model.

Why:

Linearizability is the gold-standard real-time consistency model where every operation appears to take effect instantaneously at some point between its invocation and response. Models weaker than linearizability include: eventual consistency (replicas converge eventually but may diverge temporarily, as in many NoSQL systems), read-your-writes (a session guarantee ensuring a client always sees its own writes, but not providing real-time global ordering), and monotonic read consistency (a session guarantee ensuring a client never observes a value revert to an older state across successive reads). Strict serializability combines linearizability with serializability and is at least as strong as linearizability — not weaker — so it is not chosen to boost availability. Two-phase commit (2PC) is an atomic commitment protocol for distributed transactions, not a consistency model at all, so it does not belong in this hierarchy.

System Design/sd-data/cap-consistency

A team is migrating a social-media feed system from a single SQL database to a distributed architecture. Order the following design steps from first to last when reasoning about consistency trade-offs using the CAP theorem framework:#

Put these in order

Show answer

The correct order is: (1) Identify consistency requirements per operation, (2) Accept that partitions will occur (partition tolerance is non-negotiable in distributed systems), (3) Choose CP or AP based on business requirements, (4) Select a replication strategy (sync/async) to match the chosen model, and (5) Implement conflict-resolution or read-repair to handle divergence. This order ensures business needs drive architecture decisions before implementation details are chosen.

Why:

The correct design reasoning follows this order: (1) First, identify consistency requirements per operation, since different operations may tolerate different levels of staleness — e.g., a feed read can tolerate eventual consistency but a payment debit cannot. (2) Accept partition tolerance as a given in distributed systems; CAP makes clear partitions will happen. (3) Choose CP vs AP based on business needs — for a social feed, high availability is often preferred, pointing to AP. (4) Select a replication strategy (sync vs async) to implement the chosen model. (5) Finally, implement conflict resolution or read-repair to handle the divergence that arises under the selected approach (e.g., last-write-wins or CRDTs for AP systems).

System Design/sd-data/cap-consistency

In the CAP theorem, a distributed system can choose to forgo partition tolerance and instead guarantee both consistency and availability at all times.#

Options

Show answer

False. Network partitions are a fact of distributed systems, not something you can design away. CAP says that during a partition you must sacrifice either consistency (CP) or availability (AP) — you do not get to opt out of partitions. The only systems that can claim both at all times are effectively single-node.

Why:

Network partitions are a fact of distributed systems, not a design option — links fail, nodes get isolated, and packets drop. CAP says that during a partition you must sacrifice either consistency (CP) or availability (AP); you do not get to opt out of partitions. The only systems that can claim CA are effectively single-node (or behave as one), which is why the practical choice is always CP vs AP under partition.

System Design/sd-data/cap-consistency

What does the CAP theorem force you to trade off during a network partition?#

Show answer

During a network partition the nodes on either side cannot communicate, and CAP says you must choose between consistency and availability for that period. A CP system refuses or blocks requests it cannot serve correctly so it never returns stale or conflicting data, sacrificing availability. An AP system keeps accepting reads and writes on both sides to stay available, accepting that replicas will temporarily diverge and reconcile later. When the network is healthy you can have both, so the trade-off only bites under a partition.

Why:

CAP states that when a partition splits the cluster, a distributed system can preserve either consistency (every read sees the latest write) or availability (every request gets a non-error response), not both. CP stores (e.g. classic quorum systems) reject requests they cannot serve safely; AP stores (e.g. Dynamo-style) stay up and reconcile divergence afterward. Outside a partition the choice is moot, which is why PACELC extends CAP to also describe the latency-vs-consistency trade in normal operation.

System Design/sd-patterns/rate-limiting

Design a distributed rate limiter for a public API gateway. Every incoming request must be checked against a per-API-key quota before it reaches a backend.#

Show answer

Requirements. The limit is per API key over a rolling window (1,000/min), checked on every request. I'd confirm: is a brief burst above the steady rate acceptable (token bucket says yes, up to the bucket size), and — most importantly — if the counter store is unavailable, do we fail open (let requests through, protect availability) or fail closed (reject, protect the backend)? For a public gateway I default to fail-open with alerting, since rate limiting is a guardrail, not the product.

Algorithm. I'd use a sliding-window counter (or token bucket). Fixed-window counters are simplest but allow ~2× the limit across a boundary: a client sends 1,000 in the last second of minute N and another 1,000 in the first second of N+1. The sliding-window counter weights the previous window's count by the overlap fraction, smoothing that out at a fraction of the cost of a full per-request log. Token bucket is the equivalent framing when you want to allow controlled bursts: refill at limit/60 per second, cap the bucket at the burst size.

Distributed counter. Counters live in a shared in-memory store (Redis) so all gateway nodes see the same count. The check must be atomic — a read-modify-write from two nodes races and under-counts — so I use INCR + EXPIRE (or a small Lua script that does increment, TTL, and the limit comparison in one round trip). The API key is the Redis key, so all operations for one key land on one shard.

Accuracy vs latency. A central store is exact but adds a network hop to every request. To hold <5 ms p99, I keep the store cell-local (one Redis per region/cell, no cross-region hop) and accept that limits are enforced per-region. If even one hop is too much, the alternative is local per-node token buckets that sync counts every few hundred ms — fast and highly available, but approximate (a key can briefly exceed the global limit by roughly the number of nodes). I'd start central-per-cell and only move to local+sync if the hop proves too costly.

Failure modes. Store down: fail open, serve requests un-limited, and alert. Hot key: a single key's counter is one Redis key on one shard, so a 200K-req/sec key hammers that shard — I'd detect it and shard that key's counter into N sub-counters (key:0..N) summed on read, or shed it at the edge. Clock skew: window algorithms key off time, so I rely on the store's clock (single source) rather than each node's wall clock.

Scaling. At ~500K ops/sec the counter store is sharded by key across a Redis cluster; because each key's ops stay on its shard, adding shards scales throughput linearly. Replicas give availability, and per-cell stores keep latency flat as we add regions. The bottleneck is always the hottest single key, handled by sub-sharding as above.

Why:

A distributed rate limiter is the canonical 'shared mutable counter in the hot path' problem. The two decisions interviewers probe are the algorithm (sliding-window counter or token bucket, because fixed-window allows a 2× burst across the window boundary) and where the counter lives (a shared atomic store is exact but adds a hop; local counters with sync are fast but approximate — the <5 ms budget forces you to pick a point on that spectrum). The atomic increment-and-check (INCR+EXPIRE or Lua) is what prevents concurrent nodes from racing and under-counting. The dominant failure modes are the fail-open/fail-closed choice when the store dies and the hot-key problem, where one key's counter overloads its single shard.

System Design/sd-data/cap-consistency

You are designing a globally-distributed key-value store that must remain available (AP) under network partitions. After a partition heals, the system runs an anti-entropy reconciliation process.#

Options

Pick every one that applies.

Show answer

An AP system with HLC-based replication can guarantee eventual consistency (all replicas converge once writes stop) and causal consistency (by propagating HLC metadata with replication messages and having each replica delay applying an update until its causal dependencies are met — no synchronous coordination needed). Monotonic reads, RYOW without sticky sessions, and linearizability all require cross-replica synchronisation that violates availability during partitions.

Why:

An AP system can trivially guarantee eventual consistency (its defining property) and, with careful implementation, causal consistency — because causality only requires that a replica not apply an update until all updates it causally depends on (tracked via HLC vectors) have also been applied; this does not require synchronous coordination and thus does not sacrifice availability. Monotonic reads and RYOW require sticky sessions or version-tagged reads routed to sufficiently up-to-date replicas; the question states reads can go to any replica, so neither is globally guaranteed without additional machinery. Linearizability requires a synchronous global quorum, which conflicts with availability under partition (by the CAP theorem) and contradicts the stated single-replica write acknowledgement.

System Design/sd-data/cap-consistency

A fintech company runs a distributed ledger across three datacenters (US-East, EU-West, APAC). Their current design uses multi-master replication with last-write-wins (LWW) conflict resolution.#

Show answer

Problem 1 — Silent data loss: LWW silently discards one of the two legitimate debit operations. The $300 or $500 deduction is permanently lost, causing the ledger to be incorrect; the bank either under-charges or creates phantom money, violating auditability and regulatory compliance.

Problem 2 — Clock skew vulnerability: LWW relies on wall-clock timestamps, but clocks across datacenters drift and can be manipulated. Millisecond-level skew can arbitrarily determine which write 'wins', making correctness dependent on clock synchronisation rather than application semantics.

Alternative strategy — Commutative/CRDT-based delta ledger: Model the account balance as a PN-Counter (Positive-Negative CRDT) where each debit is stored as an independent, immutable delta operation (operation-based CRDT / event sourcing). Instead of storing the absolute balance, each datacenter appends signed delta events (–$500, –$300) with a unique logical ID. On merge, all deltas from all datacenters are unioned, and the balance is derived by summing them. Because union of sets is commutative, associative, and idempotent, no write is ever lost. For stronger guarantees, combine this with a per-account distributed lock or a saga/2PC pattern for high-value transactions.

Why:

This question probes deep understanding of why LWW is inappropriate for non-idempotent, non-commutative operations like financial debits. The two core problems are (1) semantic data loss — one legitimate write is silently dropped, corrupting the ledger — and (2) dependence on unreliable wall-clock ordering. The canonical solution for financial systems is to move from state-based replication to operation/delta-based replication (event sourcing or CRDTs), where all concurrent writes are preserved and the final state is computed deterministically from the full set of operations. Alternatively, avoiding multi-master for high-value accounts via distributed locking or 2PC is a valid operational trade-off.

Related interview questions

Job market

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

The other 4 questions

This page shows 10 and marks what you pick. That's as far as a page can go. A free account opens the other 4 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

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.