System Design 101
How to scale a website to 1 million users:
// 🧵
• Prelaunch:
↳ Use a static web framework to save costs
• 10 Users:Â
↳ Use a single virtual machine to run the entire website for simplicity
• 100 Users:
↳ Use separate virtual machines to run the backend and database to prepare for scale
• 1K Users:
↳ Setup more availability zones for resilience
↳ Use serverless to handle infrequent workloads
↳ Run a monolith architecture to keep things simple
↳ Use leader-follower database replication to scale reads
• 10K Users:
↳ Install autoscaling to scale quickly
↳ Replicate stateless web server for scale
↳ Cache popular reads to reduce infrastructure load
↳ Use load balancer to route traffic and increase performance
↳ Put static content, such as images and videos, in CDN for scale and low latency
↳ Setup a 3-tier architecture on separate virtual machines for scale and maintainability
• 100K Users:
↳ Use microservices for scale
↳ Add more availability zones for reliability and scale
↳ Add cache between the backend and database to reduce server load
↳ Introduce containers and kubernetes to reduce operational complexity
• 1M Users:
↳ Federate and partition database for scale
↳ Deploy servers across more regions for scale
↳ Setup a global load balancer to route traffic across regions for scale
The bottom line:
There are many ways to scale a website to 1 million users and this is simply one of them.
The best solution and the numbers depend on your needs.
Remember, everything is a tradeoff.
——
What's your approach for scaling a website to 1 million users?