Scaling Web Applications: Vertical vs Horizontal Scaling
Understand the fundamental scaling strategies for web applications, including vertical vs horizontal scaling and the role of load balancers.
What is Scalability?
Scalability is the ability of an application or infrastructure to handle an increasing workload without degrading performance. As user volume grows, the system must adapt by utilizing resources efficiently.
Vertical vs Horizontal Scaling
-
Vertical Scaling (Scale Up): Adding more horsepower (CPU, RAM, SSDs) to a single server instance.
- Pros: Simple configuration, low latency, no network communication overhead.
- Cons: Hard hardware limits, single point of failure (SPOF), and high cost scaling curve.
-
Horizontal Scaling (Scale Out): Adding more servers/machines to the system resource pool.
- Pros: High availability, infinite scaling limits, and cost efficiency using commodity hardware.
- Cons: High architectural complexity, requires load balancing, and introduces data consistency challenges.
Horizontal scaling partition tradeoffs are explained in detail in the CAP Theorem guide.
Nginx Load Balancer Configuration
http {
upstream myapp {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}
server {
listen 80;
location / {
proxy_pass http://myapp;
}
}
}Real-world Scaling Case Study
A startup begins with a single AWS EC2 instance running both the web server and PostgreSQL (Vertical Scaling). When concurrent traffic passes 10,000 users, they split the database onto RDS, place the web servers in an Autoscaling Group behind an Application Load Balancer (ALB), and introduce caching layers (Horizontal Scaling).