categories.performance Basic
Horizontal vs Vertical Scaling
Compare horizontal and vertical scaling and their appropriate use cases.
Vertical Scaling (Scale Up)
Upgrade hardware on a single machine (CPU, memory, storage).
Pros: Simple, no code changes required.
Cons: Physical limits, rapidly increasing costs, single point of failure.
Horizontal Scaling (Scale Out)
Add more machines of the same spec; traffic is distributed by a Load Balancer.
Pros: Theoretically unlimited, high availability (HA), dynamically scale with load.
Cons: Applications must be stateless; session and cache need centralized management.
Stateless Design
Horizontal scaling requires stateless app servers: store sessions in Redis, files in S3, so any server can handle any request equally.
Decision Criteria
- Small application, short-term: vertical scaling.
- High availability, long-term growth: horizontal scaling.
- After hitting vertical DB limits: consider Read Replicas or Sharding.
✦ AI Mock Interview
Type your answer and get instant AI feedback
Sign in to use AI scoring
