InterviewHubPRO
Section Overview
Q3

Question 3 of 50

Part 1: Foundational Distributed Systems Concepts & Trade-offs (1 - 10)

6%
System Design (50 Qs)•Part 1: Foundational Distributed Systems Concepts & Trade-offs (1 - 10)

The CAP Theorem & PACELC Theorem Deep-Dive.

In Simple Words: The CAP Theorem states that a distributed data store can guarantee at most two of three characteristics simultaneously in the presence of a network partition:

  1. Consistency (C): Every read receives the most recent write or an error.
  2. Availability (A): Every non-failing node returns a non-error response for every request (without guaranteeing latest data).
  3. Partition Tolerance (P): The system continues to operate despite arbitrary network drops or delayed packets between nodes.

Because network cables and switches inevitably fail in real datacenters, Partition Tolerance (P) is mandatory. Distributed systems must choose between CP (Consistency over Availability) and AP (Availability over Consistency).

The PACELC Theorem (Extension): If there is a Partition (P), trade off Availability (A) vs Consistency (C); Else (E), trade off Latency (L) vs Consistency (C).

System TypePACELC ClassificationReal-World Database ExamplesPrimary Use Case
CP / ECPartition: Consistency; Normal: ConsistencyHBase, Spanner, ZookeeperBank balances, financial ledger
AP / ELPartition: Availability; Normal: Low LatencyApache Cassandra, Amazon DynamoDBSocial media feeds, IoT telemetry
TunableConfigurable Read/Write QuorumsMongoDB, Cassandra ($R + W > N$)Balance between ACID and scale
typescript
// Quorum Math for Strict Consistency (CP) in Distributed Key-Value Stores:
// N = Total Replicas, W = Write Quorum, R = Read Quorum
// Strict Consistency Guarantee: W + R > N (ensures read overlap with latest write)

export function isStrictlyConsistent(replicas: number, writeQuorum: number, readQuorum: number): boolean {
  return writeQuorum + readQuorum > replicas;
}

// Example: 3 Replicas (N=3), Write Quorum=2 (W=2), Read Quorum=2 (R=2)
// W + R = 4 > 3 -> Guarantees at least 1 node in read set holds the latest write!