Nextgen Blog
HomeLearnAIQuantumRoboticsSecuritySpaceAbout
Nextgen Blog

By Anubhav — full stack engineer, IIT Mandi CSE. Deep dives into AI, software engineering, and the technologies shaping the next generation of tech.

Navigate

  • Home
  • Learn
  • Blog
  • Archive
  • About

Topics

  • Artificial Intelligence
  • Quantum Computing
  • Robotics
  • Cybersecurity
  • Space Tech

Connect

Built with ❤️ & By - Anubhav

© 2026 Nextgen Blog by Anubhav. All rights reserved.

Privacy PolicyTerms of Service
Phase 01 · Foundations & Web ArchitectureChapter 1 of 33
00.
Phase 01Read time ~16 minDifficulty advanced

System Design Roadmap & Fundamentals

A complete, production-grade learning roadmap from web application fundamentals to high-scale distributed architectures, databases, and consensus protocols.

In this chapter
  • 01What Is System Design?
  • 02Why Do We Need System Design?
  • 03Problem 1 — Too much traffic
  • 04Problem 2 — Database becomes slow
  • 05Problem 3 — Expensive repeated operations
  • 06Problem 4 — One component fails
  • 07System Design Is Mostly About Trade-offs
  • 08Strong consistency
  • 09Eventual consistency
  • 10Functional vs Non-Functional Requirements
  • 11Functional Requirements
  • 12Non-Functional Requirements
  • 13Scalability
  • 14Vertical Scaling
  • 15Horizontal Scaling
  • 16Availability
  • 17Reliability
  • 18Latency
  • 19Throughput
  • 20Capacity
  • 21Durability
  • 22Consistency
  • 23Fault Tolerance
  • 24Stateful vs Stateless Systems
  • 25Stateless
  • 26Stateful
  • 27Single Server Architecture
  • 28Distributed Architecture
  • 29The Major Building Blocks
  • 30A Simple Mental Model for System Design
  • 31Traffic
  • 32Data
  • 33Performance
  • 34Availability
  • 35Consistency
  • 36Scalability
  • 37Reliability
  • 38Security
  • 39Cost
  • 40The Most Important System Design Questions
  • 41What are we building?
  • 42Who uses it?
  • 43What does it need to do?
  • 44How well must it work?
  • 45How much traffic?
  • 46Where does data live?
  • 47How do we make it faster?
  • 48How do we scale?
  • 49What happens when something fails?
  • 50How do we secure it?
  • 51How do we observe it?
  • 52What are the trade-offs?
  • 53Example: Starting a URL Shortener
  • 54Functional requirements
  • 55Basic architecture
  • 56System Design vs Low-Level Design
  • 57System Design / High-Level Design
  • 58Low-Level Design
  • 59How We Will Approach Every Real System
  • 60Common Beginner Mistakes
  • 61Mistake 1 — Starting with technologies
  • 62Mistake 2 — Adding microservices everywhere
  • 63Mistake 3 — Ignoring scale
  • 64Mistake 4 — Ignoring failure
  • 65Mistake 5 — Ignoring data consistency
  • 66Mistake 6 — Drawing boxes without explaining them
  • 67Interview Mindset
  • 68What You Should Eventually Be Able to Do
  • 69Chapter Summary
  • 70System Design
  • 71Scalability
  • 72Availability
  • 73Reliability
  • 74Latency
  • 75Throughput
  • 76Capacity
  • 77Durability
  • 78Consistency
  • 79Fault tolerance
  • 80Horizontal scaling
  • 81Vertical scaling
  • 82Stateless architecture
  • 83Distributed system
  • 84The Core Mental Model
  • 85Practice Exercises
  • 86Beginner
  • 87Intermediate
  • 88Design Exercise
  • 89What Comes Next?
  • 90Chapter 01 — How a Web Application Works
In this chapter (90 sections)
01What Is System Design?02Why Do We Need System Design?03Problem 1 — Too much traffic04Problem 2 — Database becomes slow05Problem 3 — Expensive repeated operations06Problem 4 — One component fails07System Design Is Mostly About Trade-offs08Strong consistency09Eventual consistency10Functional vs Non-Functional Requirements11Functional Requirements12Non-Functional Requirements13Scalability14Vertical Scaling15Horizontal Scaling16Availability17Reliability18Latency19Throughput20Capacity21Durability22Consistency23Fault Tolerance24Stateful vs Stateless Systems25Stateless26Stateful27Single Server Architecture28Distributed Architecture29The Major Building Blocks30A Simple Mental Model for System Design31Traffic32Data33Performance34Availability35Consistency36Scalability37Reliability38Security39Cost40The Most Important System Design Questions41What are we building?42Who uses it?43What does it need to do?44How well must it work?45How much traffic?46Where does data live?47How do we make it faster?48How do we scale?49What happens when something fails?50How do we secure it?51How do we observe it?52What are the trade-offs?53Example: Starting a URL Shortener54Functional requirements55Basic architecture56System Design vs Low-Level Design57System Design / High-Level Design58Low-Level Design59How We Will Approach Every Real System60Common Beginner Mistakes61Mistake 1 — Starting with technologies62Mistake 2 — Adding microservices everywhere63Mistake 3 — Ignoring scale64Mistake 4 — Ignoring failure65Mistake 5 — Ignoring data consistency66Mistake 6 — Drawing boxes without explaining them67Interview Mindset68What You Should Eventually Be Able to Do69Chapter Summary70System Design71Scalability72Availability73Reliability74Latency75Throughput76Capacity77Durability78Consistency79Fault tolerance80Horizontal scaling81Vertical scaling82Stateless architecture83Distributed system84The Core Mental Model85Practice Exercises86Beginner87Intermediate88Design Exercise89What Comes Next?90Chapter 01 — How a Web Application Works

1. What Is System Design?#

System Design is the process of deciding how the components of a software system should work together to satisfy a set of requirements.

When we build a small application, we can often put everything on one machine:

User
  |
  v
Application
  |
  v
Database

That may work for a small number of users.

But imagine the application suddenly has:

  • 10 million users
  • 1 million requests per second
  • users from many countries
  • millions of database records
  • large media files
  • strict uptime requirements
  • millions of concurrent connections

A single server is no longer enough.

The architecture evolves:

                    +----------------+
                    |    Clients     |
                    +-------+--------+
                            |
                            v
                    +---------------+
                    |      CDN      |
                    +-------+-------+
                            |
                            v
                    +---------------+
                    | Load Balancer |
                    +-------+-------+
                            |
              +-------------+-------------+
              |             |             |
              v             v             v
          +-------+     +-------+     +-------+
          | App 1 |     | App 2 |     | App 3 |
          +---+---+     +---+---+     +---+---+
              |             |             |
              +-------------+-------------+
                            |
                +-----------+-----------+
                |                       |
                v                       v
          +-----------+           +-----------+
          |   Cache   |           | Database  |
          +-----------+           +-----------+

System Design is about understanding why these components are needed, how they interact, what can fail, and what trade-offs are involved.


2. Why Do We Need System Design?#

The main reason is that software systems grow.

A simple application might begin as:

Browser → Server → Database

As usage increases, problems appear.

Problem 1 — Too much traffic#

One server cannot process every request.

Solution:

                Load Balancer
                 /    |    \
                /     |     \
             Server Server Server

Problem 2 — Database becomes slow#

Millions of requests hit the database.

Possible solutions:

  • indexes
  • caching
  • read replicas
  • partitioning
  • sharding
  • query optimization

Problem 3 — Expensive repeated operations#

Suppose 100,000 users request the same popular product.

Without caching:

100,000 requests
       |
       v
   Database

With caching:

100,000 requests
       |
       v
      Cache
       |
       +---- Cache Hit → Return result
       |
       +---- Cache Miss → Database

Problem 4 — One component fails#

If one server fails:

Users → Server X → FAILURE

A highly available design might use:

             Load Balancer
              /          \
             v            v
          Server A     Server B
             |            |
             +-----+------+
                   |
                Database

If Server A fails, Server B can continue serving traffic.


3. System Design Is Mostly About Trade-offs#

There is rarely one universally perfect architecture.

For example:

Strong consistency#

You may want every user to immediately see the latest data.

Advantage:

  • easier correctness model

Potential cost:

  • more coordination
  • potentially higher latency

Eventual consistency#

Different replicas may temporarily contain different values.

Advantage:

  • can improve availability and scalability

Trade-off:

  • users may temporarily see stale data

System Design therefore involves questions such as:

What are we optimizing for?

Examples:

  • latency
  • throughput
  • availability
  • consistency
  • cost
  • simplicity
  • durability
  • scalability

A strong system designer understands the trade-off instead of simply memorizing technologies.


4. Functional vs Non-Functional Requirements#

This distinction is fundamental.

Functional Requirements#

Functional requirements describe what the system should do.

For a URL shortener:

  • user submits a long URL
  • system generates a short URL
  • user opens the short URL
  • system redirects to the original URL

For a messaging application:

  • send message
  • receive message
  • show message history
  • show delivery status

Non-Functional Requirements#

Non-functional requirements describe how well the system should perform.

Examples:

  • support 10 million users
  • 99.99% availability
  • response time under 200 ms
  • encrypted communication
  • tolerate server failures
  • handle traffic spikes

A useful mental model:

Functional Requirements
        |
        | What?
        v
What does the system do?
 
Non-Functional Requirements
        |
        | How well?
        v
How should the system behave?

Both are necessary.


5. Scalability#

Scalability is the ability of a system to handle increasing workload by adding resources or changing architecture.

Suppose our server handles:

1,000 requests/second

Traffic increases to:

10,000 requests/second

We need to scale.

Vertical Scaling#

Make one machine more powerful.

Before:
 
+-----------+
| 4 CPU     |
| 16 GB RAM |
+-----------+
 
After:
 
+-----------+
| 32 CPU    |
| 128 GB RAM|
+-----------+

Advantages:

  • simple
  • minimal architectural changes

Limitations:

  • hardware limits
  • expensive at high scale
  • single-machine failure remains a concern

Horizontal Scaling#

Add more machines.

              Load Balancer
             /      |      \
            v       v       v
         Server  Server  Server
            1       2       3

Advantages:

  • supports large scale
  • redundancy
  • easier distribution of traffic

Challenges:

  • distributed state
  • networking
  • coordination
  • consistency
  • deployment complexity

Modern large-scale systems frequently rely heavily on horizontal scaling.


6. Availability#

Availability describes how often a system is operational and accessible.

Consider:

System available
      |
      v
Users can successfully use it

Availability is commonly discussed using percentages.

Examples:

Availability Approximate yearly downtime
99% 3.65 days
99.9% 8.76 hours
99.99% 52.6 minutes
99.999% 5.26 minutes

The more availability we require, the more engineering effort is generally required.

Techniques include:

  • redundancy
  • replication
  • failover
  • health checks
  • multi-zone deployment
  • multi-region deployment

7. Reliability#

Availability and reliability are related but not identical.

Availability asks:

Is the system currently available?

Reliability asks:

Does the system consistently perform correctly over time?

For example, a payment system that is available but occasionally charges users twice is not behaving reliably.

Reliability involves:

  • correctness
  • fault tolerance
  • retries
  • idempotency
  • data durability
  • recovery
  • monitoring

8. Latency#

Latency is the time required to complete an operation.

Example:

Client
  |
  | Request
  v
Server
  |
  | 120 ms
  v
Client

Latency = approximately 120 ms.

In system design, we often care about:

  • average latency
  • p50
  • p95
  • p99
  • p99.9

Why are percentiles important?

Suppose:

99 users → 50 ms
1 user  → 5 seconds

The average may hide the experience of that one user.

Tail latency tells us what slower users experience.


9. Throughput#

Throughput measures how much work a system can process in a period of time.

For APIs, we often use:

Requests per second (RPS)

or:

Queries per second (QPS)

Example:

Server processes:
 
10,000 requests/second

Its throughput is approximately:

10,000 RPS

Other systems may use:

  • messages/second
  • transactions/second
  • events/second
  • MB/second
  • GB/second

10. Capacity#

Capacity is the amount of workload a system can handle while satisfying its requirements.

Suppose:

One server = 2,000 RPS

Expected traffic:

10,000 RPS

A simplified calculation:

10,000 / 2,000 = 5 servers

But production architecture should account for:

  • peak traffic
  • failures
  • headroom
  • uneven workloads
  • deployment capacity

Therefore we might intentionally run more than the mathematical minimum.

Capacity planning becomes a major topic later in the course.


11. Durability#

Durability means that successfully stored data should not be lost unexpectedly.

For example, after a payment is recorded, we expect that record to survive:

  • server failure
  • restart
  • hardware failure
  • infrastructure problems

Durability is commonly improved through:

  • replication
  • backups
  • durable storage
  • geographically distributed copies

12. Consistency#

Consistency describes how users observe data across different copies or operations.

Imagine:

Database Primary
       |
       +------ Replica A
       |
       +------ Replica B

If a user updates:

Balance = ₹1,000

but a replica temporarily still reports:

Balance = ₹500

we have a consistency issue from the user's perspective.

Later we will study:

  • strong consistency
  • eventual consistency
  • causal consistency
  • linearizability
  • quorum-based approaches

13. Fault Tolerance#

A fault-tolerant system continues operating despite failures.

Failures can include:

  • server crash
  • database failure
  • network failure
  • disk failure
  • service timeout
  • region outage
  • software bug

Instead of assuming:

Nothing will fail.

System design assumes:

Something will eventually fail. How does the system respond?

This is one of the most important mindset changes in system design.


14. Stateful vs Stateless Systems#

Stateless#

A server does not need to remember previous requests locally.

Request 1 → Server A
Request 2 → Server B
Request 3 → Server C

Any server can handle any request.

This makes horizontal scaling easier.

Stateful#

A server keeps important session/state information locally.

User → Server A
       |
       +--- User state

If the next request reaches Server B, the state may be unavailable.

Stateful systems are not inherently bad, but distributed state requires careful design.


15. Single Server Architecture#

A beginner application might look like:

              Internet
                 |
                 v
          +-------------+
          | Web Server  |
          | Application |
          +------+------+
                 |
                 v
          +-------------+
          |  Database   |
          +-------------+

This is easy to build.

But consider:

  • server failure
  • traffic spikes
  • database bottlenecks
  • geographic users
  • large files
  • high availability

The architecture eventually needs additional components.


16. Distributed Architecture#

A distributed system spreads computation or data across multiple machines.

Example:

                         Users
                           |
                           v
                         CDN
                           |
                           v
                    Load Balancer
                           |
             +-------------+-------------+
             |             |             |
             v             v             v
          App A         App B         App C
             |             |             |
             +-------------+-------------+
                           |
                +----------+----------+
                |                     |
                v                     v
              Cache               Database
                                    |
                          +---------+---------+
                          |                   |
                          v                   v
                      Replica A           Replica B

Now we gain:

  • scalability
  • redundancy
  • fault tolerance
  • better performance

But complexity increases.

That is a recurring System Design principle:

Distribution solves some problems while creating new ones.


17. The Major Building Blocks#

Throughout this course, repeatedly encounter these components:

Component Main purpose
Client Sends/receives requests
DNS Resolves domain names
CDN Serves content closer to users
Load Balancer Distributes traffic
API Gateway Entry point for APIs/services
Application Server Executes business logic
Cache Speeds up repeated reads
SQL Database Structured persistent data
NoSQL Database Flexible/distributed data models
Object Storage Large files/media
Message Queue Asynchronous processing
Stream Platform Event streaming
Search Engine Fast text/search queries
Monitoring Observability
Service Mesh Service-to-service infrastructure

We will study each one deeply.


18. A Simple Mental Model for System Design#

When you see a system-design problem, think through these layers:

                USERS
                  |
                  v
             NETWORK / DNS
                  |
                  v
              CDN / EDGE
                  |
                  v
           LOAD BALANCER
                  |
                  v
          API / APPLICATION
                  |
          +-------+-------+
          |       |       |
          v       v       v
       CACHE   QUEUE   SEARCH
          |       |       |
          +-------+-------+
                  |
                  v
              DATABASE
                  |
                  v
               STORAGE

Then ask:

Traffic#

How many users?

How many requests?

What is peak traffic?

Data#

How much data?

How fast does it grow?

Performance#

What latency is acceptable?

Availability#

What happens if a server fails?

Consistency#

How fresh must the data be?

Scalability#

What happens when traffic becomes 10× larger?

Reliability#

What happens when components fail?

Security#

Who can access what?

Cost#

What infrastructure is reasonable?


19. The Most Important System Design Questions#

For almost every design problem, develop the habit of asking:

1. What are we building?#

Define the system.

2. Who uses it?#

Understand users and clients.

3. What does it need to do?#

Functional requirements.

4. How well must it work?#

Non-functional requirements.

5. How much traffic?#

Estimate scale.

6. Where does data live?#

Choose storage.

7. How do we make it faster?#

Caching, indexing, CDN, optimization.

8. How do we scale?#

Replication, sharding, horizontal scaling, asynchronous processing.

9. What happens when something fails?#

Fault tolerance.

10. How do we secure it?#

Authentication, authorization, encryption, rate limiting.

11. How do we observe it?#

Logs, metrics and traces.

12. What are the trade-offs?#

Explain why one approach was selected over another.


20. Example: Starting a URL Shortener#

Suppose we are asked:

Design a URL shortener like Bitly.

Don't immediately draw 20 boxes.

Start with requirements.

Functional requirements#

Long URL
   |
   v
Short URL

Example:

https://example.com/very/long/path
                 |
                 v
             abc123

Opening:

https://short.ly/abc123

should redirect to the original URL.

Basic architecture#

User
 |
 v
Load Balancer
 |
 v
Application Server
 |
 +-------> Cache
 |
 +-------> Database

Then we ask:

  • How many users?
  • How many URLs?
  • How many redirects per second?
  • How long should URLs live?
  • Do we need analytics?
  • What happens if the database is unavailable?
  • Can cached redirects become stale?
  • How do we generate unique IDs?

Notice that System Design starts with questions, not technology names.


21. System Design vs Low-Level Design#

These are related but different.

System Design / High-Level Design#

Focuses on:

Services
Databases
Caches
Queues
Networks
Scaling
Availability
Architecture

Example:

Client
  ↓
Load Balancer
  ↓
API Servers
  ↓
Redis
  ↓
PostgreSQL

Low-Level Design#

Focuses more on:

Classes
Interfaces
Objects
Methods
Design patterns
Code structure

Example:

class PaymentService {
    processPayment()
    refundPayment()
}

This course primarily focuses on System Design / High-Level Design, while we will also connect architecture decisions to implementation where useful.


22. How We Will Approach Every Real System#

For each major case study, we will use a consistent framework:

1. Requirements
       ↓
2. Scale estimation
       ↓
3. APIs
       ↓
4. Data model
       ↓
5. Basic architecture
       ↓
6. Database choice
       ↓
7. Caching
       ↓
8. Scaling
       ↓
9. Reliability
       ↓
10. Security
       ↓
11. Observability
       ↓
12. Bottlenecks
       ↓
13. Trade-offs
       ↓
14. Final architecture

This framework will eventually become your interview methodology.


23. Common Beginner Mistakes#

Mistake 1 — Starting with technologies#

Bad:

Let's use Kafka, Redis, Kubernetes and MongoDB.

Better:

What problem are we solving?

Then select technologies based on requirements.


Mistake 2 — Adding microservices everywhere#

Microservices are not automatically better.

A small application might be better served by:

Modular Monolith

rather than:

20 Microservices

Architecture should follow requirements.


Mistake 3 — Ignoring scale#

A design for:

1,000 users

is different from a design for:

100 million users

Always estimate workload.


Mistake 4 — Ignoring failure#

Ask:

What happens if this component goes down?

For every important component.


Mistake 5 — Ignoring data consistency#

If multiple copies of data exist, ask:

How do these copies stay consistent?


Mistake 6 — Drawing boxes without explaining them#

A system-design diagram is not enough.

You must explain:

  • why each component exists
  • how data flows
  • what happens during failure
  • how it scales
  • what trade-offs exist

24. Interview Mindset#

A system-design interview is not simply:

Draw the most complicated architecture possible.

It is a conversation about engineering decisions.

A strong design discussion looks like:

Requirement
    ↓
Constraint
    ↓
Design choice
    ↓
Trade-off
    ↓
Result

For example:

We expect significantly more reads than writes, so we can use read replicas to scale reads. This introduces replication lag, so operations requiring the latest value should use the primary.

That is system-design reasoning.


25. What You Should Eventually Be Able to Do#

By the advanced stage, given:

Design a global video-sharing platform.

You should naturally think:

Requirements
     ↓
Traffic estimation
     ↓
Upload architecture
     ↓
Object storage
     ↓
Video transcoding
     ↓
Metadata database
     ↓
CDN
     ↓
Caching
     ↓
Queues
     ↓
Search
     ↓
Recommendations
     ↓
Multi-region architecture
     ↓
Reliability
     ↓
Observability
     ↓
Security
     ↓
Cost & trade-offs

You will not memorize this architecture.

You will derive it from the requirements.


26. Chapter Summary#

The most important concepts from this chapter are:

System Design#

Designing how system components interact to satisfy functional and non-functional requirements.

Scalability#

Ability to handle increasing workload.

Availability#

Ability to remain accessible.

Reliability#

Ability to consistently behave correctly.

Latency#

Time required to complete an operation.

Throughput#

Amount of work processed per unit of time.

Capacity#

Maximum workload a system can handle under defined constraints.

Durability#

Ability to preserve successfully stored data.

Consistency#

How data is observed across replicas and operations.

Fault tolerance#

Ability to continue operating despite failures.

Horizontal scaling#

Adding more machines.

Vertical scaling#

Increasing machine capacity.

Stateless architecture#

Requests can be handled independently by different servers.

Distributed system#

A system whose components operate across multiple machines.


27. The Core Mental Model#

Remember this:

                 SYSTEM DESIGN
                       |
        +--------------+--------------+
        |              |              |
        v              v              v
   REQUIREMENTS      SCALE         CONSTRAINTS
        |              |              |
        +--------------+--------------+
                       |
                       v
                 ARCHITECTURE
                       |
        +--------------+--------------+
        |              |              |
        v              v              v
     COMPUTE        STORAGE        NETWORK
        |              |              |
        +--------------+--------------+
                       |
                       v
              SCALABILITY
                       |
                       v
              RELIABILITY
                       |
                       v
                 SECURITY
                       |
                       v
                OBSERVABILITY
                       |
                       v
                 TRADE-OFFS

The goal of this course is to make this reasoning process natural.


28. Practice Exercises#

Beginner#

  1. Explain System Design in your own words.
  2. What is the difference between scalability and availability?
  3. What is latency?
  4. What is throughput?
  5. What is horizontal scaling?
  6. What is vertical scaling?
  7. Why are load balancers useful?
  8. What is caching?
  9. What is a distributed system?
  10. Why do systems need redundancy?

Intermediate#

  1. Why is horizontal scaling difficult for stateful applications?
  2. Why might a database become a bottleneck?
  3. Why does caching improve performance?
  4. Why can distributed systems be more complex than single-server systems?
  5. What trade-offs are involved in eventual consistency?

Design Exercise#

Design this system:

A simple URL shortener supporting 1 million users.

Start with:

Requirements
↓
Traffic
↓
Architecture
↓
Database
↓
Cache

Do not worry about advanced technologies yet.


29. What Comes Next?#

Chapter 01 — How a Web Application Works#

We will follow one request from beginning to end:

User types:
https://example.com
 
        ↓
 
Browser
        ↓
DNS
        ↓
IP Address
        ↓
TCP
        ↓
TLS
        ↓
HTTP Request
        ↓
Load Balancer
        ↓
Web/Application Server
        ↓
Database
        ↓
HTTP Response
        ↓
Browser
        ↓
User

We will build the foundation needed to understand every architecture that comes later in this course.

Finished this chapter?

Mark it as complete to track your mastery.

Next ChapterSystem Design — Zero to Hero
Next