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

Batch Processing vs Stream Processing

Batch Processing vs Stream Processing

batch processing

stream processing

event-driven architecture

hard
·
8 min
·Updated Aug 2026·Credit: Grokking the System Design Interview

A payroll system runs once a month. A fraud detector must decide before the card transaction completes. Both process data. The difference in when the answer is needed changes everything about how they are built.

Batch processing collects data over a period and processes it all at once, on a schedule. Stream processing handles each record as it arrives, and never stops.

The decision is not about which is more modern. It is about one question. How stale may the answer be? A stale answer is one built from old data. Batch answers are hours behind. Stream answers are seconds behind, and you pay for the difference.

Image
The same records on two schedules: batch collects them and processes on a schedule, stream processes each one on arrival

Batch Processing

Data accumulates in a store, usually a data lake or a warehouse. A job then runs against the whole collection on a schedule: hourly, nightly, or monthly.

The input is bounded, which means it has a clear start and end. The job sees a complete set of records, and that gives it real advantages.

  • It can see everything at once. It can sort the full dataset, join two very large tables, and make several passes over the same records.
  • It can fail safely. If a nightly job crashes halfway, you fix the bug and run it again on the same input. The result is identical. That re-run property makes batch systems easy to trust.
  • It is cheap and simple. The work runs in bursts, often on cheap spare capacity, and nothing runs between jobs.

Typical tools: Apache Spark, Hadoop MapReduce, and a scheduler such as Airflow.

Good fits: payroll, billing runs, nightly reports, warehouse loads, retraining a machine learning model, and any backfill, which means reprocessing history.

What it costs: freshness. The answer is only as fresh as the last run. If the job runs at 2 am, a question asked at 3 pm is answered with data thirteen hours old.

Stream Processing

Records are processed as they arrive, one at a time or in very small groups. The input is unbounded, which means it has no end. So the job runs forever, and the answer is always seconds behind.

The hard part is that you never hold the complete dataset. You work with an endless sequence, and you must decide how much of it to keep in memory. That decision creates three ideas that do not exist in batch.

Windows. The stream never ends, so a count needs a boundary. A window is that boundary, such as "purchases in the last five minutes". Windows come in three shapes.

  • Fixed: each five-minute block, counted separately.
  • Sliding: the last five minutes, recomputed every minute.
  • Session: one user's activity, grouped until a gap appears.
Image
Three ways to cut an endless stream: fixed blocks, a sliding frame that recomputes as it moves, and session windows that end at a gap

Late events. A phone loses signal in a tunnel and uploads its events ten minutes later. Those events belong to a window you already closed and reported. You have three options, and each has a cost. Drop the events. Hold windows open longer, using a watermark, a rule that says how late a record may arrive before its window closes. Or close on time and send a correction later.

Image
A late event arrives after its window closed; you drop it, hold windows open with a watermark, or send a correction later

Delivery guarantees. A processing node dies in the middle of a record. Was that record handled? Most systems promise at-least-once delivery, so the record may be processed twice. Your logic must then be idempotent, meaning that doing the work twice has the same effect as once. Exactly-once processing exists in Flink and Kafka Streams, and it costs more and must be configured on purpose.

Typical tools: Apache Flink, Kafka Streams, and Spark Structured Streaming.

Good fits: fraud detection, live dashboards, alerting, and anything where a late answer is the same as no answer.

What it costs: more parts to operate, harder debugging, and a system that must stay up at all times. A failed batch job is re-run tomorrow. A failed stream job is an incident now.

The Trade-off

BatchStream
InputBounded, a finished setUnbounded, never ends
RunsOn a scheduleAt all times
FreshnessHours behindSeconds behind
Cost per recordLower, work runs in burstsHigher, always-on infrastructure
A failure isA re-runAn incident
Reprocessing historyNatural, point the job at old dataAwkward, needs a replay or a second path
ComplexityLowerHigher, windows and late events

Two rows deserve a closer look. The first is cost per record. Batch is cheaper for the same volume, because streaming infrastructure runs whether data is flowing or not. If nobody needs the answer sooner, paying for streaming is paying for nothing.

The second is reprocessing. Business logic changes, and someone will ask you to recompute the last two years under the new rules. Batch does this naturally. A pure streaming system needs either a stored event log to replay, or a separate batch path added later.

Using Both

Many companies run both paths on the same data. The streaming path produces fast, approximate numbers for dashboards and alerts. A nightly batch path recomputes the same numbers exactly and replaces them. This two-path design is called a Lambda architecture, and its cost is clear: you maintain the same logic twice. The alternative, called a Kappa architecture, keeps only the stream. To reprocess, it replays a durably stored event log through a new version of the job. That works when the log, often Kafka with long retention, keeps history for as long as you need.

Image
The Lambda architecture runs a fast approximate stream path and an exact nightly batch path on the same events; the Kappa alternative keeps only the stream and replays the log

Choosing

Ask the one question again. How stale may this answer be before it stops being useful?

  • A day is fine: batch. It is cheaper and simpler, and simpler systems break less.
  • Seconds, or the answer is worthless: stream. Fraud checks, alerts, and live pricing genuinely cannot wait.
  • Minutes: look at micro-batching. A micro-batch is a small batch job run every few minutes. It is often fresh enough, with far less infrastructure.
  • History will be recomputed: keep a batch path, or a replayable log. Someone always asks for the recompute eventually.

💡 In the interview: do not choose streaming because it sounds more impressive. Interviewers notice when a candidate adds Kafka and Flink to a system whose users would not notice a nightly refresh. State the freshness the requirement implies, then pick. If you choose streaming, expect follow-up questions on windows and late events, because that is where the design work is. A concrete answer helps: "five-minute fixed windows, a two-minute watermark, and later events go to a correction topic."

Key takeaway: batch processes a bounded set on a schedule. It is cheap, simple, and safe to re-run, and its answers are hours old. Stream processes an unbounded flow at all times. Its answers are seconds old, and it brings real complexity: windows, late events, and delivery guarantees. Decide by asking how stale the answer may be, and say the number. Expect large systems to run both, with a fast approximate stream path and an exact batch path behind it.

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

On This Page