TechCoder.io / System Design

Horizontal vs Vertical Scaling

Understand when to scale up (vertical) vs scale out (horizontal), how to design stateless services for horizontal scaling, session management at scale, and autoscaling strategies.

By TechCoder TeamLast updated: 2026-10-17
In a Nutshell

Understand when to scale up (vertical) vs scale out (horizontal), how to design stateless services for horizontal scaling, session management at scale, and autoscaling strategies. This hands-on tutorial focuses on practical implementation of horizontal vs vertical scaling concepts.

Horizontal vs Vertical Scaling

Scalability is the ability of a system to handle increasing load by adding resources. There are two fundamental approaches: scaling up (get a bigger machine) or scaling out (get more machines).

Horizontal vs Vertical Scaling Diagram

Vertical Scaling (Scale Up)

Vertical scaling means upgrading the existing server — more CPU, more RAM, faster SSD.

Pros & Cons of Vertical Scaling

✅ Pros❌ Cons
Simple — no code changes neededHard ceiling — biggest machine has limits
No distributed system complexitySingle point of failure — one machine goes down, system dies
Lower latency (no network hops)Downtime required for hardware upgrade
Great for databases (initially)Expensive — cost scales super-linearly

Horizontal Scaling (Scale Out)

Horizontal scaling means adding more servers of the same size and distributing load across them.

The Golden Rule: Stateless Services Enable Horizontal Scaling

PYTHON PLAYGROUND
⏳ Loading editor…

Scaling Strategies in Practice

Autoscaling

Modern cloud platforms (AWS, GCP, Azure) support autoscaling — automatically adding or removing servers based on load.

Metric TriggerActionExample
CPU > 70% for 5 minScale out (add servers)AWS EC2 Auto Scaling
CPU < 20% for 10 minScale in (remove servers)Save cost at night
Request queue depth > 100Scale out workersSQS + Lambda
Custom metric (RPS)Scale out web serversK8s HPA

[!TIP] Scale out for stateless services, scale up for stateful (databases). Databases are hard to horizontally scale — start with vertical scaling and read replicas, then shard only when absolutely necessary.

Quiz

Quiz

Question 1 of 2

What is the primary reason horizontal scaling requires stateless services?

Horizontal scaling uses more servers which need less memory
When any server can handle any request, the load balancer can freely distribute traffic — no sticky sessions needed
Stateless services are faster than stateful services

Official Resources

Key Takeaways

✅ Vertical scaling is simple but has a hardware ceiling and creates a single point of failure.
✅ Horizontal scaling is the key to massive scale — but requires stateless services.
✅ Make services stateless by moving session state to external shared storage (Redis).
✅ Autoscaling dynamically matches capacity to demand — critical for cost efficiency at scale.
✅ Scale databases vertically first, add read replicas, then shard — horizontal DB scaling is complex.

What's Next?

Now that we can add more servers, we need to distribute traffic across them.
Next: Load Balancing — algorithms, layers, and how to pick the right strategy.