Concepts/2. Compute & Scaling/Vertical vs Horizontal Scaling
📈
2. Compute & ScalingBeginner

Vertical vs Horizontal Scaling

← All 150+ Concepts

Vertical scaling upgrades a single node (CPU/RAM). Horizontal scaling adds stateless worker nodes across an autoscaling pool behind a load balancer.

STAFF ENGINEER TAKEAWAY: Stateless application servers scale horizontally with near-linear cost; databases eventually require sharding.
🔄

Horizontal Cluster Expansion Flow

1
CPU Metric > 80%
CloudWatch triggers alarm
✓
2
Autoscaler Controller
Orders +4 container replicas
✓
3
Health Check Probe
Pod passes /ready in 5s
✓
4
Load Balancer Target
Spreads 25,000 QPS across 8 nodes
✓
✓ ARCHITECTURAL ADVANTAGES

Horizontal scaling has no hardware ceiling and offers high resilience.

✗ TRADE-OFFS & COMPLEXITIES

Requires stateless services and centralized distributed caches (Redis).

🏢

Production Systems Leveraging This Pattern

Uber Architecture↗⚡AWS EC2 Auto ScalingGoogle Search Architecture↗
Simulate in Visual Canvas→Read 30-Chapter Curriculum→

More Topics in 2. Compute & Scaling

⚖️Load Balancing (Layer 4 vs Layer 7)

Distributes incoming client requests across a pool of backend servers using algorithms like Round Robin, Least Connections, and IP Hash.

🛡️Reverse Proxy (NGINX / Envoy)

An intermediary proxy server that sits in front of web servers to terminate TLS, compress payloads (Brotli/Gzip), cache responses, and hide internal network topologies.

🚪API Gateway Pattern

Single unified gateway entry point for microservices that handles JWT verification, rate limiting, protocol translation (REST to gRPC), and request routing.

🍩Consistent Hashing & Virtual Nodes

Maps keys and nodes onto a circular hash ring [0, 2^32 - 1]. Adding or removing a node only redistributes K/N keys rather than re-indexing the entire database cluster.