CodeWithYash
DSA
Spring Boot
System Design
Series
Articles
Leaderboard
Sign In

Subscribe to Newsletter

Get the latest articles, DSA sheets, and system design challenges delivered to your inbox.

<CODEWITHYASH/>

The ultimate sanctuary for software engineers seeking deep mastery of core technical principles.

Library

  • Articles
  • DSA Sheets
  • Roadmaps

Connect

  • GitHub
  • LinkedIn
  • About
  • Contact

Legal

  • Privacy
  • Terms
  • Support

© 2026 CodeWithYash Global Systems.

Status: OperationalVersion: 4.2.0
System Design
OverviewTheory lessonsHLDLLD
All SeriesSeries
Distributed Systems

System Design Series

0%

0 of 33 topics completed

Progress
Hardware Numbers Every Systems Engineer Must KnowCore
20 min
Network Protocols & Real-Time Communication ParadigmsCore
25 min
Latency vs. Throughput & The Tail at ScaleCore
25 min
Scalability Dimensions & Universal LawsCore
25 min
Availability, SLOs, SLIs & Error BudgetsCore
20 min
ACID vs. BASE & The Consistency SpectrumCore
30 min
CAP Theorem & PACELC FrameworkCore
25 min
System DesignFoundations & Mental ModelsACID vs. BASE & The Consistency Spectrum

Foundations · Phase 1: Foundations

ACID vs. BASE & The Consistency Spectrum

Deconstruct database transaction guarantees from Serializable isolation down to Eventual consistency, exploring snapshot isolation, dirty reads, and write skew.

Primary specification: A Critique of ANSI SQL Isolation Levels (Berenson et al.)

Written & reviewed by Yash Patel 30 minBaseline 2026.1 Curated Blueprint· Verified 2026-09-14

Lesson 6 of 33

1d streak

The Architectural Question

Teams assume Read Committed isolation prevents race conditions, resulting in silent inventory overselling and corrupted account balances.

Core Engineering Objectives

  • ACID transaction boundaries: Atomicity, Consistency invariants, Isolation levels, Durability
  • ANSI SQL isolation anomalies: Dirty Read, Non-Repeatable Read, Phantom Read, Write Skew
  • BASE model: Basically Available, Soft state, Eventual consistency with causal ordering

1. What is it & Why it Matters

ACID and BASE represent the two foundational approaches to data management: - ACID (Pessimistic & Centralized): Guarantees strict transactional correctness. If any part of an update fails, the entire transaction is rolled back. - BASE (Optimistic & Distributed): Embraces network latency and partial failure by trading immediate consistency for continuous availability and low latency.

The Core Architectural Trade-Off

Strong consistency requires coordination (locks, two-phase commits, consensus rounds), which adds latency and degrades availability. Eventual consistency enables instant local writes, but requires the application to tolerate temporary read staleness.

2. ACID Demystified

Atomicity

All or nothing. Either all database operations in the transaction succeed, or all changes are rolled back.

Consistency

The database moves only between valid states that satisfy all declared schema constraints and business invariants.

Isolation

Concurrent transactions do not observe each other’s intermediate, uncommitted updates (enforced via row locks or MVCC).

Durability

Once a transaction commits, its data survives crashes and power cuts (flushed to Write-Ahead Log on persistent disk).

3. BASE & The Consistency Spectrum

Basically Available

The system guarantees availability for all requests, even if nodes must return degraded or slightly stale data during partial outages.

Soft State

Data values may change over time without explicit user writes as replicas asynchronously catch up.

Eventual Consistency

Given sufficient time with no new updates, all replicas converge to identical data.

Architectural Boundary · Do Not Confuse

Concept A

ACID (Relational - Postgres, MySQL)

Concept B

BASE (NoSQL - Cassandra, DynamoDB)

ACID describes transaction properties, while BASE is an informal description of systems that may expose temporary inconsistency. Neither label alone determines scalability or partition behavior; the actual transaction, replication, and consistency model does.

4. Decision Guide & Consistency Cheat Sheet

Consistency LevelWhat It GuaranteesLatency / CostReal-World Example
Strict Serializability / LinearizabilityEvery read sees the latest global write instantaneouslyHigh (multi-node consensus / locks)Bank ledgers, distributed locks (etcd)
Causal ConsistencyOperations causally related are seen in the same order everywhereModerate (tracked via vector clocks)Comment threads, collaborative doc editing
Read-Your-WritesA user always observes updates submitted by their own sessionLow (pin user reads to primary replica for 5s)User profile updates, account settings
Eventual ConsistencyReplicas synchronize asynchronously in the backgroundLowest (local reads/writes without locks)DNS propagation, video view counts, social feeds

Use it when

Choose ACID when modeling financial balances, seat reservations, or authentication state where reading stale data causes fraud or business loss.

Reconsider when

Choose BASE when building high-velocity telemetry, chat presence, notification streams, or social feeds where 100% write availability outweighs microsecond consistency.

5. Active Recall Checkpoint

Active Recall Checkpoint

What is "Read-Your-Writes" consistency and how is it typically implemented in a primary-replica database setup?

Hint: Think about routing read queries for a short window after a user performs a write.

Show answer & explanation

Read-Your-Writes guarantees that a user will immediately observe their own updates, even if other users see eventual consistency. In a primary-replica architecture, it is implemented by routing reads to the primary database for 5–10 seconds following a user write (or tracking the write's replication timestamp/LSN), while routing all other reads to replicas.

Engineering Decision Matrix

Architectural Trade-Off Analysis

Compare latency, throughput, consistency, and operational complexity across core industry alternatives.

Architectural Trade-Off Matrix

Architecture Decision Matrix

Multi-axis engineering evaluation and FAANG interview rules of thumb.

Option A

SQL (Postgres / MySQL)

Relational ACID Store

Structured schema, relational joins, ACID transactions, and strict foreign keys.

Option B

NoSQL (Cassandra / DynamoDB)

Distributed Non-Relational Store

Horizontal partition keys, denormalized documents/wide-columns, and tunable consistency.

Evaluation AxisSQL (Postgres / MySQL)NoSQL (Cassandra / DynamoDB)Details
Latency
Moderate Strong
Throughput
Moderate Strong
Scalability
Moderate Strong
Consistency
Strong Moderate
Complexity
Strong Moderate
Cost
Moderate Strong
FAANG Interview Rule of Thumb

When to Choose in an Architecture Interview

Pick SQL (Postgres / MySQL) If:

Choose SQL when ACID guarantees are non-negotiable (financial ledgers, payment processing, inventory checkout) or when query access patterns are unpredictable and require ad-hoc analytical joins.

Pick NoSQL (Cassandra / DynamoDB) If:

Choose NoSQL when write volume exceeds single-node capacity (>20K writes/sec), data is unstructured/hierarchical (logs, telemetry, user feeds), or multi-region active-active replication is mandatory.

Examiner Trap to Avoid:

Never say "NoSQL is faster than SQL" without qualification. SQL with proper B-Tree indexes on indexed primary keys is lightning fast. NoSQL wins on horizontal write scaling, not inherent single-row read speed.

Production Postmortem & Verification

Production Incident Postmortem

  1. Trigger / Setup: Two concurrent transactions check `SELECT SUM(balance)` before withdrawing funds under standard Read Committed isolation.
  2. Production Symptom: Both transactions read the initial positive balance and commit withdrawals simultaneously, leaving the account overdrawn.
  3. Root Cause & Fix: Read Committed does not guard against phantom rows or write skew; use pessimistic SELECT FOR UPDATE or serializable conflict detection.

Acceptance Criteria & Outcomes

  • Define exact SQL isolation levels and identify which anomalies each level tolerates.
  • Explain Multi-Version Concurrency Control (MVCC) mechanics and why Snapshot Isolation allows write skew.
  • Map out the consistency spectrum: Strict Linearizability > Sequential > Causal > Monotonic Reads > Eventual.

End-of-Chapter Synthesis & Key Takeaway

ACID vs. BASE & The Consistency Spectrum is built around one fundamental rule: Establish clear responsibility and explicit trade-offs.. Before adding components, establish explicit quantitative SLAs for latency, throughput, and consistency. Choose the simplest architecture that meets stated constraints.

Architectural & Technical Interview Review

Core FAANG Interview Questions

3 Questions
Q01
How do you justify introducing ACID vs. BASE & The Consistency Spectrum into a high-scale production architecture?
Click to reveal model answer →Hide answer ↑Requirements & Design Brief

Introduce ACID vs. BASE & The Consistency Spectrum only when measured scale, data size, or failure boundaries exceed single-node capacity. State the exact bottleneck, evaluate operational overhead, and verify that the trade-offs justify the added moving parts.

Source section: Requirements & Design Brief
Q02
What is the primary trade-off and hidden operational cost of ACID vs. BASE & The Consistency Spectrum?
Click to reveal model answer →Hide answer ↑Architecture Trade-offs

It improves scalability and availability, but introduces network hops, serialization overhead, and eventual consistency or coordination complexity.

Source section: Architecture Trade-offs
Q03
How do you handle catastrophic failure or dependency degradation in ACID vs. BASE & The Consistency Spectrum?
Click to reveal model answer →Hide answer ↑Failure Review & Recovery

Implement connect/read timeouts, exponential backoff with jitter, and fallback defaults so downstream degradations do not cause cascading outages.

Source section: Failure Review & Recovery

Production Pitfalls & Anti-Patterns

Critical Failure Anti-Patterns

!

Premature Distributed Complexity

Scattering distributed components before identifying concrete write, read, or storage limits creates accidental points of failure and operational debt.

Production Mitigation: Start with the simplest modular design that satisfies requirements, evolving it only as measured constraints dictate.

!

Unbounded Retries and Cascading Storms

When a dependency degrades, immediate synchronized retries multiply downstream traffic, turning a minor slowdown into a total fleet outage.

Production Mitigation: Enforce strict retry budgets, exponential backoff, and full randomized jitter on all client calls.

!

Neglecting Observability and Metrics

Deploying architecture without distributed tracing or p99 tail latency alerts leaves engineers blind when partial partitions occur.

Production Mitigation: Export metrics for request rate, error rate, p95/p99 duration, and saturation at every service boundary.

Primary Documentation & Specifications

A Critique of ANSI SQL Isolation Levels (Berenson et al.)
Previous LessonAvailability, SLOs, SLIs & Error BudgetsFoundationsNext LessonCAP Theorem & PACELC FrameworkFoundations

In this chapter

01Architectural Question021. What is it & Why it Matters032. ACID Demystified043. BASE & The Consistency Spectrum054. Decision Guide & Consistency Cheat Sheet065. Active Recall Checkpoint07Trade-Off Analysis08Production Verification09Synthesis & Review10Primary References

Chapter promise

ACID transaction boundaries: Atomicity, Consistency invariants, Isolation levels, Durability