Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Blog/System Design

How to scale a website from 1 user to 1 million users

A home router copes with 10 devices, not 200. Websites too. Here is how one server grows into a million-user site, one bottleneck at a time.

Derpx063 Oct · 5 min read
Contents
What does the simplest version look like?Why give the database its own machine?What does a load balancer do?How does a cache give the database a break?What are read replicas?Do images and videos need special treatment?What about slow jobs like emails?What if even the primary can't keep up?How many requests is "a million users"?Design it yourselfSources
0% read · 5 min leftBack to top ↑
On this page0%
Contents
What does the simplest version look like?Why give the database its own machine?What does a load balancer do?How does a cache give the database a break?What are read replicas?Do images and videos need special treatment?What about slow jobs like emails?What if even the primary can't keep up?How many requests is "a million users"?Design it yourselfSources

A home Wi-Fi router works fine for 10 devices and struggles with 200. Websites have the same problem, just with more zeros.

So how does a site go from one user (you, testing) to a million without melting? Short answer: you don't plan for a million on day one. You find the one thing slowing everything down, fix only that, and wait for the next one. Here is the list.

A shop that gets busy

One person at the counter is fine for ten customers. At a hundred you add more staff and more counters. Each fix shows you the next crowded spot.

What does the simplest version look like?

One server runs your code and your database together, like a small school project. It's a fine place to start.

The problem: this machine does two jobs, and if it dies, everything dies. So we split the jobs. Which one goes first?

Why give the database its own machine?

Move the database to a separate server. Now the app and the database stop competing for the same CPU and memory. Making a machine bigger is called scaling up, and it works until the biggest machine you can buy isn't big enough.

Stage 0One box does everything. Busy app slows the database.
→
Stage 1App server and database server. Each has its own resources.

Scaling up is easy but has a ceiling. And one app server is still a single point of failure. What next?

What does a load balancer do?

You run several copies of the app and put a load balancer in front. It's like a traffic officer who spreads requests across your servers. Per AWS, it also does health checks, so it stops sending traffic to a server that's failing.

Drag the slider to 12 and watch the load per server drop. Then hit "If one server dies" and see how much more work the others take on.

3
8
8
8

24 requests ÷ 3 servers = 8. Each server handles 8 requests.

A toy: 24 requests shared equally. Real load balancers don't always split perfectly evenly.

More servers means less work for each one, and a dead server just means a bit more work for the others. That's scaling out, and AWS's reliability guidance says the same thing: replace one large resource with multiple small ones, so one failure hurts less.

The catch: any server might get your next request. So keep your login and cart in the shared database, not in one server's memory. That makes servers stateless (any copy can answer).

Now all those servers send requests to one database. What next?

How does a cache give the database a break?

Most requests ask for the same things again and again, like the homepage or a popular profile. A cache is a fast memory store that keeps recent answers so you skip the database.

The common pattern (AWS calls it lazy loading): check the cache first. If it's missing, ask the database, then save the answer in the cache. Click Next and follow one request.

App
Cache
Database

App asks the cache for the answer

Step 1 of 4
Lazy loading: cache first, database only on a miss.

The database only gets the first request. The price is stale data: the cache can hold an old answer after the database changes. AWS's fix is a TTL, a timer after which the entry expires and gets refreshed. It doesn't guarantee fresh data. It only limits how old the data can get.

So reads are cheaper. But what if there are still too many reads?

What are read replicas?

Many sites mostly read (scrolling) and rarely write (posting). So you make copies of the database. One primary takes writes, and replicas copy its changes and answer reads.

PostgreSQL's docs call these primary and standby servers. A standby that accepts read-only queries is a "hot standby", and it only allows reads, no inserts or updates.

The catch is lag. The Postgres docs say the same query run on primary and standby at nearly the same time might return different results. Post something, refresh, and it may be missing for a moment.

Do images and videos need special treatment?

Yes. Images, fonts and videos are big, and the same for every user. A CDN (content delivery network) is a set of servers in many locations that keep copies of your files. AWS describes it as copies stored closer to users, which reduces latency.

Users no longer fetch the same logo from one far-away machine, and your servers get a break. AWS notes this suits static content, not content that changes per user.

What about slow jobs like emails?

Some jobs are slow: sending emails, resizing photos, making a PDF. If the request waits for them, users stare at a spinner. Instead, the app drops a note in a queue (a waiting line of tasks) and replies right away. Separate worker servers pick tasks up later.

It's like dropping a letter in a mailbox: you drop it off and move on. AWS describes queues as a way to decouple the parts of a system, so the producer and the consumer don't have to run at the same speed.

What if even the primary can't keep up?

Replicas only help with reads, so eventually the primary can't take all the writes. Then you split the data itself. Sharding means each database server holds only part of the data, like names A to M on one server and N to Z on another.

It's powerful but hard. Queries across shards get complicated, and a bad split makes one shard much busier than the others. (Postgres's partitioning splits a table inside one database, so that's a different thing.)

Bottleneck

The one part of a system that limits everything else, like one slow checkout line in a shop. Speeding up anything else won't help until you fix it.

How many requests is "a million users"?

A quick estimate, not a measurement. Say a million people open an app 10 times a day (an example number). That's 10,000,000 / 86,400 seconds, about 116 requests per second on average. Real traffic spikes, so plan for more.

Design it yourself

  1. A ticket site gets 50,000 people in one hour when sales open. Which stage helps first?
  2. A user changes their name but still sees the old one for a few seconds. Which two stages could cause that?
  3. What would you shard by in a chat app, and what goes wrong if one user is far more active than the rest?
Key takeaways
  • Scaling is fixing one bottleneck at a time, not designing for a million on day one.
  • Stateless servers behind a load balancer are what let you just add more servers.
  • Caches and replicas make reads fast, and both cost you freshness.
  • Queues and CDNs move slow and heavy work out of the way, and sharding is the last step.

Sources

  • AWS — What is load balancing?
  • AWS — What is a CDN?
  • AWS Well-Architected, Reliability Pillar — Design principles
  • AWS — Caching strategies (Amazon ElastiCache)
  • AWS — What is Amazon SQS?
  • PostgreSQL docs — High availability, load balancing, and replication
  • PostgreSQL docs — Hot standby
  • PostgreSQL docs — Table partitioning
ShareXLinkedInEmail
Written by Derpx06A developer who builds AI search tools and the code around them. I explain what I got wrong first, so you can skip it. Spotted a mistake? Tell me — corrections get credited.
System Design · 4 minHow does video streaming work? (Why movies play on slow Wi-Fi)System Design · 5 minHow does a search engine find one page out of billions so fast?System Design · 5 minWhat is Kafka? Why it keeps messages after you read them
Start here
01Why is 0.1 + 0.2 not 0.3 in code?02How does Git work inside? (Snapshots, not changes)03How does your computer know the time? (And why it can be wrong)