tezvyn:

Horizontal Scaling: Add More Machines, Not Bigger Ones

AI-drafted, machine-checkedSource: Wikipedia: Horizontal scalingbeginner

Horizontal scaling (scaling out) means handling more load by adding more machines to your resource pool, not upgrading a single one. It’s used for web servers behind a load balancer. The footgun is that your app must be stateless to avoid losing user data.

WHY IT EXISTS: Systems need to handle growing amounts of work without collapsing. When a single machine hits its physical limits of CPU or RAM, you can't just make it infinitely bigger. Horizontal scaling provides a path to near-limitless capacity by using many commodity machines instead of one expensive supercomputer.

THE MENTAL MODEL: Think of a single, overwhelmed cashier at a grocery store. Vertical scaling is like sending that cashier to a speed-training course to work faster. Horizontal scaling is simply opening more checkout lanes with more cashiers. As long as you have a system to direct customers to an open lane (a load balancer), you can handle a massive influx of shoppers.

HOW IT WORKS: Horizontal scaling involves adding more instances (nodes, servers, containers) of an application. A load balancer sits in front of these instances and distributes incoming requests among them. For this to work, each instance must be able to handle any given request. This means the application should be stateless, with any required state like user sessions stored in a shared, external service like a database or a cache.

WHEN TO USE IT: Use horizontal scaling for applications designed to be stateless, like web frontends, API gateways, and many microservices. It's ideal for workloads with unpredictable traffic spikes, as you can automatically add or remove instances based on demand (autoscaling). This is the default scaling model for most cloud-native applications.

WHEN NOT TO USE IT: Avoid horizontal scaling for applications that are inherently stateful and cannot be easily re-architected. For example, a traditional monolithic relational database can be very difficult to scale out, as data consistency across nodes becomes a major challenge. In these cases, vertical scaling (buying a bigger server) might be the simpler, albeit more limited, option.

ONE CANONICAL EXAMPLE: An e-commerce website expects a massive traffic surge on Black Friday. Instead of running on one giant server, its web application is deployed on 20 smaller virtual machines behind a load balancer. As traffic increases, an autoscaling system automatically adds 80 more machines to the pool. When the sale ends, the extra machines are removed to save costs. Each machine is identical and stateless; user cart information is stored in a separate, shared database.

Read the original → en.wikipedia.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.