System Design

Learn System Design

How to Learn System Design?

Key Characteristics of Distributed Systems

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

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

Availability

Availability

availability

high availability

fault tolerance

load balancing

+3

hard
·
20 min
·Updated Sep 2026·Credit: System Design Fundamentals

You open a train booking app at 9 PM to buy a ticket for tomorrow. The page loads for a long time, then shows "Service unavailable". You try again ten minutes later, and now it works.

For those ten minutes, the app was not available to you. Thousands of other people may have seen the same error.

This lesson answers two questions. How do we measure how often a system works? And how do we design a system that keeps working when some of its parts fail?

What Availability Means

Availability is the share of time a system works for its users. We usually write it as a percentage.

The time when the system works is called uptime. The time when it does not work is called downtime.

Availability = uptime / (uptime + downtime) x 100

Here is a small example. A 30-day month has 720 hours. Suppose a system is down for 7.2 hours in that month. Its uptime is 712.8 hours, so its availability is 712.8 / 720, which is 99 percent.

A slow system can also be down. A page that takes 40 seconds to load is still running, but most users leave before it finishes. So teams often count a slow request as a failed request. For example, a team may say that a request fails if it returns an error or takes more than 2 seconds.

Many teams count requests instead of minutes. They divide the number of successful requests by the total number of requests. Suppose a service gets 1,000,000 requests in a day and 500 of them fail. Its availability for that day is 99.95 percent.

Counting requests is fairer for systems with busy and quiet hours. A 10-minute failure at the evening peak hurts far more users than a 10-minute failure during the night.

The Nines

Availability targets are usually described by their number of nines. "Three nines" means 99.9 percent. "Four nines" means 99.99 percent.

Each extra nine allows 10 times less downtime. The table shows the allowed downtime for each target. A month here means a 30-day month.

TargetNameDowntime per yearDowntime per monthDowntime per day
99%two nines3.65 days7.2 hours14.4 minutes
99.9%three nines8.76 hours43.2 minutes1.44 minutes
99.99%four nines52.6 minutes4.32 minutes8.6 seconds
99.999%five nines5.26 minutes25.9 seconds0.86 seconds
Image
Each extra nine allows 10 times less downtime, and five nines leaves only about 26 seconds a month

The numbers show why each nine is harder to reach than the last. At 99.9 percent, a team has about 43 minutes each month to notice a problem and fix it. At 99.999 percent, it has about 26 seconds. A person cannot even open an alert in that time. So a five-nines system must find failures and recover from them without human help.

More nines also cost more. Each nine usually needs more servers, more data centers, and more engineering work. The right target depends on what the product does. A payment service needs a higher target than an internal reporting tool that people check once a week.

Planned and Unplanned Downtime

Downtime has two sources.

  • Planned downtime is chosen by the team. Examples are software upgrades, database changes, and hardware replacement.
  • Unplanned downtime is not chosen. Examples are a server crash, a bad code release, a full disk, a network failure, or a power cut.

Users do not care which kind it is. The app is down either way. For this reason, many systems avoid planned downtime too. They upgrade one server at a time while the other servers keep serving requests. This is called a rolling update.

Availability of Connected Parts

A real system is made of many parts. One request may pass through a load balancer, an application server, and a database. The availability of the whole system depends on how these parts are connected.

Parts in series. Parts are in series when a request needs every one of them. If any one part fails, the request fails. To get the total availability, multiply the availability of each part.

A(total) = A1 x A2 x A3

Suppose a load balancer is 99.99 percent available, an app server is 99.9 percent, and a database is 99.9 percent. The total is 0.9999 x 0.999 x 0.999, which is about 99.79 percent. That is about 18 hours of downtime a year.

Look at that result again. Every part was at least 99.9 percent available, but the whole system is below 99.9 percent. Each required part lowers the total availability.

Parts in parallel. Parts are in parallel when any one of them can handle the request. The request fails only when all of them fail at the same time. To get the total, multiply the chances of failure, then subtract the result from 1.

A(total) = 1 - (1 - A1) x (1 - A2)

Suppose one server is 99 percent available, so it is down 1 percent of the time. Two such servers are both down only 1% x 1% = 0.01% of the time. So the pair is available 99.99 percent of the time. Two ordinary servers together give four nines.

Image
Required parts in series multiply the total down, while copies in parallel make a full failure far less likely

The parallel formula has one condition. The copies must fail independently, which means the failure of one copy does not cause the other to fail. Two servers in the same rack share one power supply. If that power fails, both servers stop together. Two servers running the same buggy code also crash together. So real redundancy puts copies in different places, with separate power and network paths.

Single Points of Failure

A single point of failure (SPOF) is one part whose failure stops the whole system.

Here is an example. A website has three app servers and one database. If the database fails, all three app servers have no data to read. The extra app servers did not help, because the database was a single point of failure.

To find these parts, follow the path of one request through the system. For each part on the path, ask one question: "If only this part fails, does the request still work?" Every part where the answer is "no" is a single point of failure.

Image
The load balancer and the database are single points of failure until each one gets a copy

How Systems Stay Available

No system can prevent every failure. A highly available system expects parts to fail, and it keeps serving users when they do. The techniques below work together.

Redundancy

Redundancy means keeping more than one copy of every important part. There are two common ways to run the copies.

  • Active-active. All copies serve traffic at the same time. If one copy fails, the others take its share. Each copy needs spare capacity for this extra load.
  • Active-passive. One copy, the active one, serves all traffic. Another copy, the standby, waits. If the active copy fails, the standby takes over.
Image
In active-active every copy serves traffic, while in active-passive the standby waits until a failover

Active-active uses every machine, but losing one copy puts more load on the others. Active-passive is simpler, but the standby is idle most of the time. Switching to it also takes some time.

Replication

Data needs copies too. Replication means keeping copies of the same data on more than one machine. Usually one machine, the primary, accepts writes. The other machines, the replicas, receive copies of those writes. Often a copy reaches a replica a little later, so a replica can be a few seconds behind the primary. This delay is called replication lag. If the primary fails, a replica can become the new primary. The replication lesson covers the details.

Load Balancing and Health Checks

A load balancer is a server that spreads incoming requests across many servers. It sends a small test request, called a health check, to each server every few seconds. When a server stops answering, the load balancer stops sending it traffic. Users keep getting answers from the healthy servers. The load balancing lesson explains how this works.

Monitoring and Alerts

A team cannot fix a problem it does not know about. Monitoring means collecting numbers about the system all the time, like error rate, response time, and CPU use. An alert is a message sent to an engineer when one of those numbers crosses a limit.

For example, a team can send an alert when more than 1 percent of requests fail for 5 minutes. Good alerts find problems before most users notice them. Regular maintenance, like applying security patches, also prevents some failures before they happen.

Failover

Failover is the process of moving traffic from a failed part to a healthy copy. It happens in four steps.

  1. Detect. The system notices the failure. A server that misses several health checks in a row is marked as down.
  2. Decide. The system picks a healthy copy to take over. For a database, this often means making a replica the new primary.
  3. Switch. Traffic moves to the healthy copy. The load balancer or DNS settings are updated.
  4. Restore. The team or the system repairs the failed part and adds it back as a copy.
Image
Users see errors during detect, decide and switch, so faster failover means less downtime

Users see errors during the first three steps. So the downtime of one failure is the time to detect, plus the time to decide, plus the time to switch.

Here is an example. Suppose health checks run every 5 seconds, and a server is marked down after 3 missed checks. Detection alone then takes about 15 seconds. With automatic failover, the whole switch takes only seconds. A manual failover, where a person must see an alert and act, can take 30 minutes or more.

Separate Zones and Regions

Copies in the same building can fail together, for example during a fire or a power cut. So cloud providers split their data centers into zones and regions.

  • An availability zone is one data center, or a group of data centers, with its own power, cooling, and network.
  • A region is a geographic area, like Mumbai, that contains several zones.

Copies in two zones keep working if one data center fails. Copies in two regions keep working if a whole region fails. Spreading copies across locations like this is called geographic distribution. Multi-region setups cost more, and copying data over long distances adds delay.

Serve Less Instead of Failing

When one feature fails, the rest of the app can often keep working. Suppose the recommendation service of a shopping app is down. The product page can still load without the "You may also like" section. Users can still search, add items to the cart, and pay.

This is called graceful degradation. The main actions keep working while an optional feature is down. A page with one missing section is much better than an error page.

Load Shedding and Rate Limiting

Too much traffic is a common cause of downtime. When servers get more requests than they can handle, every request becomes slow. Soon, all of them start to fail.

Load shedding means rejecting some requests on purpose, with a quick "try again later" error. The system then has enough capacity to serve the remaining requests well. Rate limiting is a related idea. It limits how many requests one user or client can send in a time window.

Safe Releases

Many outages start with a new code release. Teams reduce this risk by releasing in small steps.

A canary release sends the new version to a small share of users first, like 5 percent. The team watches the error rate. If errors rise, the team does a rollback, which means going back to the previous version. Only a small group of users sees the problem.

MTBF and MTTR

Two more numbers help explain availability.

  • MTBF (mean time between failures) is the average time a system runs before it fails.
  • MTTR (mean time to repair) is the average time it takes to bring the system back after a failure.
Availability = MTBF / (MTBF + MTTR)

Suppose a system fails once every 1,000 hours on average. Each time, it takes 1 hour to bring it back. Its availability is 1,000 / 1,001, which is about 99.9 percent.

Now suppose the failures happen just as often, but automatic failover restores service in 6 minutes, which is 0.1 hours. The availability becomes 1,000 / 1,000.1, which is about 99.99 percent.

Faster recovery added a nine without reducing the number of failures. This is why monitoring and automatic failover matter so much. Failures cannot be stopped completely, but they can be made short.

SLI, SLO and SLA

Teams write availability targets down using three related terms.

  • An SLI (service level indicator) is the number you measure. An example is the percentage of successful requests over the last 30 days.
  • An SLO (service level objective) is the team's own target for that number. For example, 99.95 percent of requests succeed.
  • An SLA (service level agreement) is a promise in a contract with customers. If the provider misses it, the provider pays a penalty, often as a discount on the bill.

The SLA is usually lower than the SLO. For example, a team may set its SLO at 99.95 percent and its SLA at 99.9 percent. If the team misses its own target, it gets a warning before it breaks the customer promise.

The downtime a target allows is called the error budget. A monthly target of 99.9 percent gives an error budget of 43.2 minutes. When most of the budget is used, the team slows down new releases and works on stability first.

Availability, Reliability and Consistency

These three words are often mixed up.

  • Availability asks: does the system respond?
  • Reliability asks: does the system do the right thing, without failures, over a long time? A system can be available but not reliable. For example, it may answer every request quickly but sometimes return wrong data.
  • Consistency asks: do all copies of the data show the same value?

More copies improve availability, but copies can disagree for a short time. So every system with copies must decide how closely the copies must agree. This decision is called the consistency model.

  • Strong consistency means every copy shows the same data at all times. A write must reach every copy before it counts, so the system is less available and slower.
  • Weak consistency allows copies to disagree for a while. In return, the system is more available and faster.
  • Eventual consistency allows copies to disagree for a short time, but all copies reach the same data over time. It sits between the other two.

The hardest case is a broken network between copies. Then the system must choose. It can answer with data that may be old, and stay available. Or it can refuse to answer until the copies agree, and stay consistent. The CAP theorem describes this choice.

High availability is also different from fault tolerance, where users see no interruption at all. The Fault Tolerance vs. High Availability lesson compares the two.

Key Takeaways

  • Availability is the share of time, or of requests, that a system serves users successfully.
  • Each extra nine allows 10 times less downtime. A target of 99.9 percent allows 8.76 hours a year. A target of 99.99 percent allows 52.6 minutes.
  • Parts in series lower the total availability. Copies in parallel raise it, but only when they fail independently.
  • A single point of failure is one part that can stop the whole system. Remove it by adding a copy.
  • Redundant copies run as active-active or active-passive.
  • Copies force a consistency choice. Strong consistency keeps copies identical but lowers availability. Eventual consistency lets copies reach the same data over time.
  • The downtime of one failure is the time to detect, decide, and switch. Automatic failover keeps it short.
  • Availability = MTBF / (MTBF + MTTR). Faster recovery is often the easiest way to add a nine.
  • An SLI is what you measure, an SLO is your target, and an SLA is your promise to customers.

High availability does not come from one tool. It comes from many small decisions: copies in separate places, health checks, automatic failover, safe releases, and a clear target. Start with the target because it tells you how many of these decisions the product really needs.

Practice Questions

Try each question first, then open the answer.

1. A service is down for 72 minutes in a 30-day month. What is its time-based availability?

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

About 99.833 percent. A 30-day month has 30 x 24 x 60 = 43,200 minutes. The uptime is 43,200 - 72 = 43,128 minutes. Divide 43,128 by 43,200 and multiply by 100. The result is 99.8333 percent.

</details>

2. Out of 200,000 requests, 500 fail. What is the request-based availability?

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

99.75 percent. The number of successful requests is 200,000 - 500 = 199,500. Divide 199,500 by 200,000 and multiply by 100.

</details>

3. Two app servers share one database. Does adding a third app server remove the database as a single point of failure?

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

No. Every app server still needs the same database. If the database fails, all three app servers fail with it. The database needs its own copy, like a replica, and its own failover plan.

</details>

4. Course suggestions fail, but lessons remain usable. Which availability technique does this show?

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

Graceful degradation. The main action, reading lessons, keeps working while an optional feature, course suggestions, is unavailable.

</details>

5. A replica is ten seconds behind the primary when the primary fails. What could happen if that replica becomes the new primary?

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

Some writes may be lost. Updates from the last ten seconds had not reached the replica yet. These can include writes that the old primary already reported to users as successful. This is why some systems wait for a replica to confirm a write before they report success.

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

On This Page