What is the difference between horizontal and vertical scaling?
Answer
Vertical scaling (Scale-up): upgrade a single server to a larger, more powerful machine — add more CPU cores, RAM, faster storage, better network. Pros: simple implementation (no application changes), no distributed systems complexity, lower latency (no network between parts of the system), suitable for databases that are hard to distribute (traditional SQL). Cons: hard ceiling — maximum machine size is limited by available hardware; expensive high-end hardware; single point of failure (if the server dies, the whole service is down); downtime required for hardware upgrade. Horizontal scaling (Scale-out): add more machines (nodes) to a system and distribute the load. Pros: theoretically unlimited — add as many machines as needed; commodity hardware (cheaper); high availability — if one node fails, others continue; cloud-native (easy with auto-scaling groups). Cons: more complex — requires load balancing, stateless application design, distributed data management; network overhead between nodes; data consistency challenges; some operations don't parallelize well. What to scale first: start vertical (simpler), scale horizontal when vertical limits are reached or cost is too high. Most large systems today are horizontal. Stateless design prerequisite: horizontal scaling requires stateless application servers — no user session in local memory. Use Redis for sessions, shared storage for files. The 12-factor app methodology promotes stateless services specifically to enable horizontal scaling.
Previous
What are the ACID properties in databases?
Next
What is a content delivery network (CDN) and how does it reduce latency?