System Design

Learn System Design

How to Learn System Design?

Scalability

Availability

Latency and Performance

Concurrency and Coordination

Monitoring and Observability

Resilience and Error Handling

Fault Tolerance vs. High Availability

Flashcards Review

Chapter Assessment

HTTP vs. HTTPS

TCP vs. UDP

HTTP: 1.0 vs. 1.1 vs 2.0 vs. 3.0

URL vs. URI vs. URN

What Happens When You Type a URL into the Browser

Flashcards Review

Chapter Assessment

Introduction to Real-Time Communication

What is Long-Polling?

What is WebSocket?

What are Server-Sent Events?

Difference Between Long-Polling, WebSockets, and Server-Sent Events

Flashcards Review

Chapter Assessment

Introduction to DNS

DNS Resolution Process

DNS Load Balancing and High Availability

Flashcards Review

Chapter Assessment

What is a Proxy Server?

Uses of Proxies

VPN vs. Proxy Server

Flashcards Review

Chapter Assessment

Introduction to Load Balancing

Load Balancing Algorithms

Uses of Load Balancing

Load Balancer Types

Stateless vs. Stateful Load Balancing

High Availability and Fault Tolerance

Scalability and Performance

Challenges of Load Balancers

Flashcards Review

Chapter Assessment

Introduction to API Gateway

Usage of API gateway

Advantages and disadvantages of using API gateway

Flashcards Review

Chapter Assessment

What Is an API?

What Are REST APIs?

Resources, Not Actions

HTTP Methods and Their Semantics

URL Design

Request and Response Shapes

Status Codes and Error Design

Pagination from the Consumer's View

Idempotency Keys

Versioning and Backward Compatibility

Concurrency and Conditional Requests

REST vs gRPC vs GraphQL

Flashcards Review

Chapter Assessment

What Is Rate Limiting

Rate Limiting Algorithms

Distributed Rate Limiting

Rate Limiting in Practice

Flashcards Review

Chapter Assessment

Introduction to Caching

Why is Caching Important?

Types of Caching

Cache Replacement Policies

Cache Invalidation

Cache Read Strategies

Cache Coherence and Consistency Models

Caching Challenges

Cache Performance Metrics

Flashcards Review

Chapter Assessment

What is CDN?

Origin Server vs. Edge Server

CDN Architecture

Push CDN vs. Pull CDN

Flashcards Review

Chapter Assessment

Introduction to Data Partitioning

Partitioning Methods

Data Sharding Techniques

Benefits of Data Partitioning

Common Problems Associated with Data Partitioning

Flashcards Review

Chapter Assessment

What is Redundancy?

What is Replication?

Replication Methods

Data Backup vs. Disaster Recovery

Flashcards Review

Chapter Assessment

Introduction to CAP Theorem

Components of CAP Theorem

Trade-offs in CAP Theorem

Examples of CAP Theorem in Practice

Beyond CAP Theorem

System Design Trade-offs in Interviews

Flashcards Review

Chapter Assessment

Introduction to Databases

SQL Databases

NoSQL Databases

SQL vs. NoSQL

ACID vs BASE Properties

Real-World Examples and Case Studies

SQL Normalization and Denormalization

In-Memory Database vs. On-Disk Database

Data Replication vs. Data Mirroring

Database Federation

Flashcards Review

Chapter Assessment

What are Indexes?

How a B-Tree Index Works

Types of Indexes

B-Tree vs. LSM Tree

Indexes in Distributed Systems

Flashcards Review

Chapter Assessment

Introduction to Bloom Filters

Benefits & Limitations of Bloom Filters

Variants and Extensions of Bloom Filters

Applications of Bloom Filters

Flashcards Review

Chapter Assessment

Why Quorum?

What is Quorum?

Flashcards Review

Chapter Assessment

What is Leader and Follower Pattern?

Flashcards Review

Chapter Assessment

What is Heartbeat?

Flashcards Review

Chapter Assessment

What is Checksum?

Uses of Checksum

Flashcards Review

Chapter Assessment

Introduction to Messaging System

Introduction to Kafka

Messaging patterns

Popular Messaging Queue Systems

RabbitMQ vs. Kafka vs. ActiveMQ

Scalability and Performance

Flashcards Review

Chapter Assessment

What is a Distributed File System?

Architecture of a Distributed File System

Key Components of a DFS

Flashcards Review

Chapter Assessment

What is Security and Privacy?

What is Authentication?

What is Authorization?

Authentication vs. Authorization

OAuth vs. JWT for Authentication

What is Encryption?

What are DDoS Attacks?

Flashcards Review

Chapter Assessment

Batch Processing vs. Stream Processing

XML vs. JSON

Synchronous vs. Asynchronous Communication

Push vs. Pull Notification Systems

Microservices vs. Serverless Architecture

Message Queues vs. Service Bus

Stateful vs. Stateless Architecture

Event-Driven vs. Polling Architecture

Flashcards Review

Chapter Assessment

Quiz

System Design Trade-offs

Importance of Discussing Trade-offs

Strong vs Eventual Consistency

Latency vs Throughput

ACID vs BASE Properties in Databases

Read-Through vs Write-Through Cache

Batch Processing vs Stream Processing

Load Balancer vs. API Gateway

API Gateway vs Direct Service Exposure

Proxy vs. Reverse Proxy

API Gateway vs. Reverse Proxy

SQL vs. NoSQL

Primary-Replica vs Peer-to-Peer Replication

Data Compression vs Data Deduplication

Server-Side Caching vs Client-Side Caching

REST vs RPC

Polling vs. Long-Polling vs. WebSockets vs. Webhooks

CDN Usage vs Direct Server Serving

Serverless Architecture vs Traditional Server-based

Stateful vs Stateless Architecture

Hybrid Cloud Storage vs All-Cloud Storage

Token Bucket vs Leaky Bucket

Read Heavy vs Write Heavy System

Quiz

System Design Interviews - A step by step guide

Functional vs. Non-functional Requirements

What are Back-of-the-Envelope Estimations?

Things to Avoid During System Design Interview

System Design Master Template

Quiz

Designing a URL Shortening Service like TinyURL

Quiz - Designing URL Shortner

Designing Pastebin

Quiz - Designing Pastebin

Designing Instagram

Quiz - Designing Instagram

Designing Dropbox

Quiz - Designing Dropbox

Designing Facebook Messenger

Quiz - Designing Facebook Messenger

Designing Twitter

Quiz - Designing Twitter

Designing Youtube or Netflix

Quiz - Designing Youtube

Designing Typeahead Suggestion

Quiz - Designing Typeahead Suggestion

Designing an API Rate Limiter

Quiz - Designing an API Rate Limiter

Designing Twitter Search

Quiz - Designing Twitter Search

Designing a Web Crawler

Quiz - Designing a Web Crawler

Designing Facebook’s Newsfeed

Quiz - Designing Facebook’s Newsfeed

Designing Yelp or Nearby Friends

Quiz - Designing Yelp or Nearby Friends

Designing Uber backend

Quiz - Designing Uber backend

Designing Ticketmaster

Quiz - Designing Ticketmaster

Dynamo: Introduction

High-Level Architecture

Data Partitioning

Replication

Vector Clocks and Conflicting Data

The Life of Dynamo’s put() & get() Operations

Anti-entropy Through Merkle Trees

Gossip Protocol

Dynamo Characteristics and Criticism

Summary: Dynamo

Quiz: Dynamo

Mock Interview: Dynamo

YouTube Likes Counter

Quiz

Cassandra: Introduction

High-level Architecture

Replication

Cassandra Consistency Levels

Gossiper

Anatomy of Cassandra's Write Operation

Anatomy of Cassandra's Read Operation

Compaction

Tombstones

Summary: Cassandra

Quiz: Cassandra

Mock Interview: Cassandra

Messaging Systems: Introduction

Kafka: Introduction

High-level Architecture

Kafka: Deep Dive

Consumer Groups

Kafka Workflow

Role of ZooKeeper

Controller Broker

Kafka Delivery Semantics

Kafka Characteristics

Summary: Kafka

Quiz: Kafka

Mock Interview: Kafka

Chubby: Introduction

High-level Architecture

Design Rationale

How Chubby Works

File, Directories, and Handles

Locks, Sequencers, and Lock-delays

Sessions and Events

Master Election and Chubby Events

Caching

Database

Scaling Chubby

Summary: Chubby

Quiz: Chubby

Mock Interview: Chubby

Hadoop Distributed File System: Introduction

High-level Architecture

Deep Dive

Anatomy of a Read Operation

Anatomy of a Write Operation

Data Integrity & Caching

Fault Tolerance

HDFS High Availability (HA)

HDFS Characteristics

Summary: HDFS

Quiz: HDFS

Mock Interview: HDFS

Google File System: Introduction

High-level Architecture

Single Master and Large Chunk Size

Metadata

Master Operations

Anatomy of a Read Operation

Anatomy of a Write Operation

Anatomy of an Append Operation

GFS Consistency Model and Snapshotting

Fault Tolerance, High Availability, and Data Integrity

Garbage Collection

Criticism on GFS

Summary: GFS

Quiz: GFS

Mock Interview: GFS

BigTable: Introduction

BigTable Data Model

System APIs

Partitioning and High-level Architecture

SSTable

GFS and Chubby

Bigtable Components

Working with Tablets

The Life of BigTable's Read & Write Operations

Fault Tolerance and Compaction

BigTable Refinements

BigTable Characteristics

Summary: BigTable

Quiz: BigTable

Mock Interview: BigTable

Design Reddit

Quiz

Designing a Notification System

Quiz

Design Google calendar (Medium)

Quiz

Design a Recommendation System for Netflix

Quiz

Design Gmail

Quiz

Design Google News, a Global News Aggregator System (Medium)

Quiz

Design Unique ID Generator (Easy)

Quiz

Design Code Judging System like LeetCode (Medium)

Quiz

Design Payment System

Quiz

Design a Flash Sale for an E-commerce Site (Hard)

Quiz

Design a Reminder Alert System

Quiz

Introduction: System Design Patterns

1. Bloom Filters

2. Consistent Hashing

3. Quorum

4. Leader and Follower

5. Write-ahead Log

6. Segmented Log

7. High-Water Mark

8. Lease

9. Heartbeat

10. Gossip Protocol

11. Phi Accrual Failure Detection

12. Split Brain

13. Fencing

14. Checksum

15. Vector Clocks

16. CAP Theorem

17. PACELC Theorem

18. Hinted Handoff

19. Read Repair

20. Merkle Trees

Quiz

Strong vs Eventual Consistency

Strong vs Eventual Consistency

consistency

replication

availability

strong consistency

+1

hard
·
10 min
·Updated Sep 2026·Credit: Grokking the System Design Interview

You update your profile picture. The page reloads, and it still shows the old picture.

Nothing is broken. Your write went to one machine, and your read came back from another machine. That second machine had not received the change yet.

Almost every large system keeps copies of its data on several machines. Keeping copies is called replication, and each copy is called a replica. The Redundancy and Replication lesson explains why systems keep copies. This lesson is about the question that copies create: after a write, what does the next read see?

There are two main answers, and they have different costs:

  • Strong consistency: every read returns the most recent write. To promise this, the system makes each write wait.
  • Eventual consistency: a read is answered immediately, but it may briefly return the old value. The copies catch up shortly after.
Image
The write was saved on node A, but the reload read from node B, which had not received the change yet

Strong Consistency

A system is strongly consistent when every completed write is visible to every later read. It does not matter which client reads, or which replica answers.

Here is a common way to provide it. The write goes to the primary, which is the node that accepts writes. The primary sends the change to its replicas. It does not confirm the write to the client until enough replicas report that they have saved it. This is called synchronous replication, because the write waits for the copying.

Quorums

"Enough replicas" usually means a quorum. A quorum is the minimum number of servers that must successfully complete an operation. A common choice is a majority quorum. With 5 replicas, a majority is 3. So a write succeeds only after 3 of the 5 replicas confirm it.

A write quorum alone does not make every read correct, because 2 replicas may still be behind. So the system also reads from a quorum. Here is the rule. Add the number of replicas that confirm a write to the number that answer a read. If the total is more than the number of replicas, every read reaches at least one replica with the latest write. With 5 replicas, 3 for writes plus 3 for reads is 6, which is more than 5. The Quorum lesson explains this in more detail.

Image
With strong consistency, the client gets OK only after a quorum of 3 out of 5 replicas confirms the write

What Strong Consistency Gives You

  • Reads are always correct. No user ever sees an old value.
  • Simpler application code. The application never needs to handle a stale read, which is a read that returns an old value.

What Strong Consistency Costs You

  • Slower writes. Each write waits for the replicas it needs, plus the network time to reach them. Replicas in the same data center add about a millisecond. But a replica on another continent adds a full round trip. For example, a round trip between Virginia and Frankfurt takes about 90 ms. So a write that must wait for Frankfurt takes about 90 ms longer. This is why strong consistency across distant data centers increases write latency. No engineering can remove this delay, because it comes from distance.
  • Refused writes. If too many replicas are unreachable, the system has a choice: accept the write and break its promise, or refuse the write. A strongly consistent system refuses. With a majority quorum of 3 out of 5, the system keeps working with 2 replicas down, but not with 3 down.

The classic use for strong consistency is money. You withdraw 100 dollars from an account that holds 500 dollars. Every later read, anywhere, must show 400 dollars. If some machine still shows 500 dollars, the same money could be spent twice.

Eventual Consistency

A system is eventually consistent when its copies converge, which means they all reach the same value. If no new updates are made, all copies of the data eventually become identical. The promise is that the copies will agree, not when they will agree.

The mechanism is the same replication, without the waiting. The write goes to one node, and that node confirms it immediately. The change travels to the other replicas in the background. This is called asynchronous replication, because the copying happens after the confirmation. A read that reaches a replica before the change arrives returns the old value.

Image
With eventual consistency, one node confirms immediately and copies the change later, so reads may briefly be old

What Eventual Consistency Gives You

  • Fast writes. A write only needs one machine to confirm it.
  • Better availability. The system keeps accepting reads and writes while some replicas are unreachable, because no node waits for another.

What Eventual Consistency Costs You

  • A stale window. For a short time, updates are still spreading, so two users may briefly see different data.
  • More careful application code. The application must behave correctly when a value is briefly old.

The Domain Name System (DNS), which maps domain names to server addresses, works this way. When a domain's address changes, some DNS servers keep returning the old address for minutes or hours. Nobody calls DNS broken, because the delay is known and planned for.

How Long Is "Eventually"?

Replication lag is the delay between a write on one node and its arrival at the other copies. This number decides whether eventual consistency is acceptable.

  • Inside one data center, lag is usually a few milliseconds.
  • Across regions, lag is usually tens to a few hundred milliseconds.

For most data, the stale window ends before a user can even reload the page. But lag is not always small. It grows under heavy write load, when a restarted replica is catching up, or when a network link is slow. A replica can fall minutes behind. If lag affects correctness anywhere in your design, monitor it.

Read Your Own Writes

Users rarely notice when other people see slightly old data. They notice when they see it themselves. For example, you post a comment, the page refreshes, and your comment is missing. The system works exactly as designed, but it looks like a bug.

The fix is small. For a short time after a user writes, send that user's reads to the primary. Everyone else keeps reading from replicas. This is called read-your-own-writes consistency.

Image
Read your own writes sends the writer to the primary for a short time, while everyone else reads from replicas

Almost all traffic still uses the cheaper replica reads. And the one kind of staleness that users actually notice is removed. The cost is a small amount of routing logic, and slightly more load on the primary.

There are also levels between the two extremes:

  • Causal consistency keeps related operations in order. For example, a reply never appears before the message it answers.
  • Bounded staleness sets a limit on how old a read may be, for example 5 seconds.

Some databases, like Azure Cosmos DB and MongoDB, let you choose a consistency level for each operation.

One Page, Several Answers

A common mistake is choosing one consistency model for a whole system. Real designs choose for each piece of data.

Look at a single shopping page:

  • The account balance should be strongly consistent, because a wrong number is a real problem.
  • The stock count should be strongly consistent at checkout, because selling the last item twice costs money.
  • The view counter can be eventually consistent, because nobody notices a few seconds of delay.
  • The recommendations can be minutes old.

That is several answers on one page. So name the data, not the system. For example: "Balance reads go to the primary and are strongly consistent. Everything else is served from replicas."

Strong vs. Eventual Consistency

Strong consistencyEventual consistency
After a writeEvery read returns the new valueA read may briefly return the old value
Write speedWaits for replicas to confirmOne node confirms immediately
Replicas unreachableMay refuse writesKeeps accepting reads and writes
Copying styleSynchronousAsynchronous, in the background
Example systemsGoogle Spanner, etcd, a single primary databaseCassandra and DynamoDB by default, DNS, most caches
Good fitMoney, stock, bookingsFeeds, counters, recommendations

Think of the two models as the two ends of a range. Most real systems sit somewhere between them, on purpose.

Choosing Between Them

  • The data counts something that must be exact, like money, stock, seats, or bookings: choose strong consistency.
  • The data is content or a casual count, like feeds, likes, views, or recommendations: choose eventual consistency.
  • Users read back their own changes: choose eventual consistency, plus read-your-own-writes.
  • Replicas are in several regions, and writes must stay fast: choose eventual consistency, because strong consistency waits for the round trip on every write.
  • You cannot decide yet: start with strong consistency, and relax specific reads when measurements show the need.

Three other lessons explain the theory behind this choice. The CAP Theorem lesson explains the choice during a network partition, which is a failure that cuts machines off from each other. The PACELC Theorem lesson extends it to normal operation, where requests trade latency against consistency. The Quorum lesson explains how many replicas must confirm each read and write.

Using This in an Interview

Do not answer "strong" or "eventual" for the whole system. Split the answer. Name the one or two pieces of data that must never be stale, and send those reads to the primary. Serve everything else from replicas. Then add read-your-own-writes for each user's own data, because that is the staleness users notice.

A common follow-up question is: "How stale can a replica get?" Answer with numbers: usually a few milliseconds inside a data center, but possibly minutes while a replica is catching up. That is why replication lag is monitored.

Key Takeaways

  • Strong consistency promises that every read returns the newest write. Writes wait for replicas, and may be refused when too many replicas are unreachable.
  • Across distant data centers, strong consistency increases write latency, because synchronous replication must cross the distance.
  • A quorum is the minimum number of servers that must complete an operation. With 5 replicas, a majority quorum is 3.
  • Eventual consistency confirms writes immediately. Updates spread over time, and readers may briefly see different data.
  • If no new updates are made, all copies in an eventually consistent system become identical.
  • Read-your-own-writes removes the staleness users notice most.
  • Choose a consistency level for each piece of data, not for the whole system.

Consistency decides what readers see after a write. The next lesson, Primary-Replica vs Peer-to-Peer Replication, looks at how the machines that hold the copies are organized.

Practice Questions

Try each question first, then open the answer.

1. A database uses strong consistency, with replicas in Virginia and Frankfurt. A write in Virginia takes 5 ms locally, and each write must wait for Frankfurt to confirm. A round trip between the two takes about 90 ms. About how long does each write take, and why?

<details> <summary>Show answer</summary>

About 95 ms. The local work takes 5 ms, and waiting for Frankfurt adds a round trip of about 90 ms. This is synchronous replication: the write is not confirmed until the distant replica has it. Faster servers cannot remove the 90 ms, because it comes from the distance between the data centers.

</details>

2. A system has 5 replicas and uses a majority quorum for writes. How many replicas must confirm each write? Can the system still accept writes with 2 replicas down? With 3 replicas down?

<details> <summary>Show answer</summary>

3 replicas must confirm each write. A majority of 5 is 3. With 2 replicas down, 3 are still running, so writes can still succeed. With 3 replicas down, only 2 are running, which is less than the quorum of 3. So the system refuses writes, to keep its consistency promise.

</details>

3. A system has 5 replicas. Writes need 3 confirmations, and reads ask 3 replicas. Why does every read see the latest write? What changes if reads ask only 2 replicas?

<details> <summary>Show answer</summary>

3 + 3 = 6, which is more than 5, so the groups always overlap. At least one of the 3 replicas that answer a read must also be one of the 3 that confirmed the write. So the read finds the latest value. If reads ask only 2 replicas, 3 + 2 = 5, which is not more than 5. The 2 replicas that answer a read could both be the ones that missed the write, so the read may return an old value.

</details>

4. A user posts a comment and refreshes the page 50 ms later. The read goes to a replica, and replication lag is about 200 ms. What does the user see, and how can the design fix it?

<details> <summary>Show answer</summary>

The comment is missing, because the replica has not received it yet. The system is eventually consistent, and the user read inside the stale window. The fix is read-your-own-writes. For a short time after a user writes, send that user's reads to the primary. Other users can keep reading from replicas, and will see the comment a moment later.

</details>

5. A shopping page shows an account balance, a product's stock count, the product's view count, and recommendations. Which of these need strong consistency?

<details> <summary>Show answer</summary>

The account balance and the stock count. A wrong balance is a real problem, and a wrong stock count at checkout can sell the last item twice. The view count and the recommendations can be eventually consistent, because a short delay does no harm. So the design sends balance and stock reads to the primary, and serves the rest from replicas.

</details>
Discussion
Have a question or insight about this topic? Share it with the community.
Reading Progress
0%

On This Page