SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
  • Scalability
  • Availability
  • Reliability
  • Single Point of Failure (SPOF)
  • Latency vs Throughput vs Bandwidth
  • Consistent Hashing
  • CAP Theorem
  • Fault Tolerance and Redundancy
  • Failover
  • Stateless vs Stateful
  • Concurrency vs Parallelism
  • Capacity Planning
  • Back Pressure
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Foundations/Core Concepts

Scalability

Handling more users and more data by adding resources, without breaking.

⏱ 14 min readBeginnerMust KnowInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

Scalability means a system can handle more users, more requests and more data without becoming slow or breaking.

  • We do it by adding resources: a bigger machine, or more machines.
  • A scalable system grows step by step as the business grows.
  • Fast is not the same as scalable. Fast with 10 users but crashing with 10,000 users is NOT scalable.

02Concept: What is it?

Scalability is the ability of a system to handle a growing amount of work by adding resources, while still working fast and staying reliable.

👥Users
10 users to 10 million users
⚡Requests
How many requests arrive every second
💾Data
How much we need to store
🧠Simple rule
If the load grows 10 times, we should be able to add resources and the system should still work well. We should not need to rebuild everything.

Do not confuse these four words

WordSimple meaningQuestion it answers
PerformanceHow fast it is for one userIs it fast right now?
ScalabilityHow well it stays fast when users growWill it stay fast with 1000x users?
AvailabilityHow much of the time it is upIs it working when I need it?
ReliabilityCorrect results without failingCan I trust it?

03Real-Life Example

🍵The Tea Stall
A small tea stall has one person making tea. On day 1 he serves 20 customers. Later, 500 customers come every hour. What can the owner do?
Option A: Bigger stall
Vertical scaling
  • Buy a bigger stove, hire a stronger worker
  • Simple, but one person has a limit
  • If he falls sick, the shop closes
Option B: More stalls
Horizontal scaling
  • Open 5 stalls and a manager sends each customer to a free one
  • Can grow: 10 stalls, 50 stalls
  • If one closes, the others keep working
Tea stall as a system
🧑‍🤝‍🧑Customers
→↓
🧑‍💼ManagerLoad balancer
→↓
🍵Stall 1
🍵Stall 2
🍵Stall 3
Tea stall
Software system
Customers
Users / requests
One worker
One server
Faster worker, bigger stove
Vertical scaling
More stalls
Horizontal scaling
Manager sending customers
Load balancer
Open extra stalls only at rush hour
Auto-scaling

04Why Do We Need It?

We need it because traffic never stays the same. It grows over time, and it also jumps suddenly.

📈Business growth
1,000 users can become 1 million in 2 years.
🎟️Sudden spikes
Festival sales, cricket matches, exam results, ticket booking.
😀Happy users
Slow pages make users leave.
💥No crashes
A crash means lost money and lost trust.
💰Save money
Use more servers only when needed.
🔮Ready for the future
No costly rebuild later.
We design for scalability so that success does not break our system.

05Where Do We Use It?

Any system that can grow needs scalability.

🛒E-commerce
Huge rush on sale days
📱Social media
Millions post and view at once
🎬Video streaming
Millions watch the same match
💳Payments (UPI)
Many payments each second, no failures
🚕Ride booking
Peak hours need many drivers matched
🚆Ticket booking
Sudden rush when booking opens

Where in the system do we scale?

🌐Web / app servers
🗄️Databases
⚡Cache
📬Message queues
📦Storage

06Types / Parts / How It Works

There are two main ways to scale: make one machine bigger, or use more machines.

Vertical vs Horizontal
Vertical (scale up)
🖥️Small server4 CPU, 8 GB
↓upgrade
🖥️BIG server64 CPU, 512 GB
Horizontal (scale out)
⚖️Load balancer
↓
🖥️
🖥️
🖥️
➕add
Vertical: one machine gets stronger. Horizontal: more machines share the work.
PointVertical (up)Horizontal (out)
What it meansMore CPU, RAM, disk in one machineMore machines
Easy to do?Yes, very simpleHarder, needs design changes
Code changesUsually noneOften yes (servers should be stateless)
LimitHardware limit, very costly at the topAlmost no limit
If one machine failsEverything stops (SPOF)Others keep working
Downtime while scalingOften needs a restartUsually none
Needs load balancer?NoYes
Best forSmall apps, early databasesBig systems, web servers
💡Which one to choose?
Start simple: vertical is quick when you are small. As traffic grows, move to horizontal. Many real systems use both.

Words you will hear

  • Scale up / down: make one machine bigger / smaller.
  • Scale out / in: add / remove machines.
  • Elastic scaling (auto-scaling): machines are added and removed automatically based on load.
  • Databases are harder to scale than web servers, because data must stay correct and in sync.
VisualizerScale up or scale out?Drag the slider to add users. Try both ways to grow.
How do we grow?
👥2,000 users
↓
⚖️Load balancer
↓
🖥️S11000
🖥️S21000
Servers
2
Can handle
2,000
users
Status
OK
2 small servers share the work. Need more? Just add another one. If one fails, the others keep going.

07How to Use It / Steps / Implementation

Tools we use

TechniqueWhat it does in simple words
Load balancerSpreads requests across many servers
Stateless serversServers do not remember the user, so any server can serve any request
CachingKeeps popular data in fast memory so the database is not hit every time
CDNKeeps copies of images and videos close to the user
ReplicationCopies of the database handle read requests
ShardingSplits big data across many databases
Message queuesSlow jobs run in the background so users do not wait
Auto-scalingAdds or removes servers by itself

Typical growth path

  1. 1
    One server
    App and database together.
  2. 2
    Separate the database
    Move it to its own server.
  3. 3
    Add a load balancer
    Run many app servers (horizontal scaling).
  4. 4
    Add a cache
    Reduce load on the database.
  5. 5
    Add read replicas
    Copies of the database for reading.
  6. 6
    Add a CDN
    For images, videos and files.
  7. 7
    Add message queues
    For slow background work.
  8. 8
    Shard the database
    When one database cannot hold all the data.
  9. 9
    Go multi-region
    Data centres in different places.
💡Golden rule
First measure to find the bottleneck, then fix that part. Do not scale blindly.

08Key Terms to Know

TermMeaning in easy words
LoadThe amount of work on the system (users, requests, data)
ThroughputHow many requests the system handles per second (RPS or QPS)
LatencyHow long one request takes to get a reply
p99 latencyThe time within which 99 out of 100 requests finish. Shows the slow cases
CapacityThe maximum load the system can handle today
BottleneckThe slowest part that limits the whole system (often the database)
StatelessServer keeps no user memory between requests. Easy to scale
StatefulServer remembers user data (like a login). Harder to scale
ElasticityGrowing AND shrinking automatically with load
SPOFSingle point of failure: one part whose failure stops everything
Load testingTesting with fake heavy traffic to find the limit

09Pros, Cons and Trade-offs

✅ Pros
  • Handles growth and sudden spikes
  • Better speed for users
  • Less downtime
  • Pay only for what you use (auto-scaling)
⚠️ Cons
  • Design is more complex
  • Needs more tools: load balancers, caches, monitoring
  • Data consistency is harder across machines
  • Debugging is harder
  • Higher bill if not managed well

Trade-offs

ChoiceWe gainWe lose
Vertical scalingSimple, quickHardware limit, SPOF
Horizontal scalingAlmost unlimited growth, fault toleranceComplex design, load balancer needed
CachingVery fast readsData may be stale
ReplicationMore read capacity, backupCopies may lag behind
ShardingStore huge dataComplex queries, hard to rebalance
Async with queuesUsers do not waitResult is not instant
⚠️Do not scale too early
A small app with 100 users does not need 50 servers. Scale when the numbers show you need it.

10Common Problems and Mistakes

Common mistakes

  1. Storing sessions inside the server. The user is stuck to one server. Use a shared store like Redis.
  2. Ignoring the database. Web servers are easy to scale; the database is the first bottleneck.
  3. Scaling the wrong part. More servers will not fix a slow query.
  4. Scaling too early. More servers means more cost and complexity.
  5. No monitoring and no load testing. You find the limit only when real users crash it.
  6. Leaving a single point of failure. One load balancer or one database can still stop everything.

Problems when systems grow

🔥Hot spots
One server or shard gets far more traffic than others.
🔀Data consistency
Copies can show different values for a short time.
🐢Network delay
More machines talking adds delay.
⛓️Cascading failure
One slow part makes others fail one after another.

How to find the bottleneck

  1. Watch CPU, memory, disk and network.
  2. Check slow database queries.
  3. Check latency (especially p99) and error rate.
  4. Run a load test and see which part breaks first.

11Real-World Examples

🎬Netflix, YouTube
Videos are copied to many servers close to users (CDN).
🛒Amazon and shopping sites
Add servers automatically on sale days, remove them after.
💬WhatsApp
Huge message volume handled by many servers and queues.
📸Instagram, Facebook
User data is sharded across many databases, with heavy caching.
💳UPI payments
Many requests per second spread across many servers.
🚆Train ticket booking
A rush at opening time needs extra capacity and queues.
📝Note
These are general ideas. The exact details inside each company are more complex.
Mini case: a small blog goes viral
👥100,000 visitors
→↓
🌍CDNimages, files
→↓
⚖️Load balancer
→↓
🖥️
🖥️
🖥️
→↓
⚡Cache
🗄️Database
Users CDN Traffic split App servers Cache
One server crashes under 100,000 visitors. The fix is a CDN, a cache and 3 servers behind a load balancer.

12Related Topics to Read Next

Availability→

A scalable system should also stay up while it grows.

Reliability→

More machines means more chances of failure.

Single Point of Failure (SPOF)→

Scaling out removes single points of failure.

What are Load Balancers?→

The main tool to share traffic across many servers.

Consistent Hashing→

Add or remove servers with little data movement.

CAP Theorem→

The limits when data is spread across machines.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • ✔What: handle more load by adding resources, while staying fast and reliable.
  • ✔Two types: vertical (bigger machine) and horizontal (more machines).
  • ✔Prefer: horizontal for big systems, vertical for small and simple ones.
  • ✔Key tools: load balancer, cache, CDN, replication, sharding, queues, auto-scaling.
  • ✔Key rule: keep app servers stateless.
  • ✔First bottleneck: usually the database.
  • ✔Always: measure first, then scale the real bottleneck.
  • ✔One line: “Scalability is the ability to handle growth by adding resources without losing speed or reliability.”
← Previous
30 Must-Know Concepts
Next →
Availability