CLOUD CONCEPT

Horizontal Scaling

Horizontal scaling adjusts capacity by adding or removing servers, containers, or other processing units that share a workload.

Cloud Concepts Hub →

What is Horizontal Scaling

Instead of making one machine larger, horizontal scaling distributes work across multiple resources. It helps applications handle changing demand and can improve resilience, while requiring suitable workload distribution and state management. When automated to match demand, it provides elasticity.

Horizontal scaling changes the number of resources serving a workload rather than changing the size of an individual resource. Adding resources is called scaling out; removing them is called scaling in. For example, a web application might expand from two application servers to six during a busy period, then return to two when traffic decreases. Vertical scaling, by contrast, changes the CPU, memory, or other capacity of an individual server.

In cloud environments, horizontal scaling commonly uses virtual machines, container tasks, or managed execution environments. A load balancer distributes incoming requests across available application instances. For background processing, multiple workers can consume jobs from a shared queue without requiring a request-routing load balancer. Each additional resource contributes useful capacity only when the workload can be divided among resources.

Auto scaling provides elasticity by automatically adjusting capacity to changing demand. Scaling policies can respond to measurements such as CPU utilization, requests per target, or queue backlog per worker. Scheduled scaling can prepare capacity for predictable traffic patterns. In AWS, Amazon EC2 Auto Scaling can change the number of EC2 instances in an Auto Scaling group within configured limits. For certification questions, distinguish scalability, the ability to handle changing workload, from elasticity, the adjustment of provisioned capacity to match demand.

Applications scale more easily when individual processing instances do not hold essential local state. A shopping application can store its cart data in a shared data store so that any application instance can handle the next request. Keeping sessions or uploaded files only on one instance creates routing dependencies and risks losing data when that instance is removed. Stateful systems can also scale horizontally, but may require replication, partitioning, and explicit consistency decisions.

Scaling is not instantaneous. New resources need time to start, initialize dependencies, and pass readiness checks before accepting work. Engineers should configure minimum and maximum capacity, appropriate scaling metrics, and instance warmup behavior. During scale-in, connection draining and graceful shutdown help avoid interrupting requests or abandoning jobs. Queue workers should tolerate retries and use idempotent processing where duplicate delivery is possible.

More application instances do not automatically produce proportional performance gains. A shared database, external API rate limit, network constraint, or serialized operation may remain the bottleneck. Horizontal scaling also adds costs and operational complexity, including monitoring, distributed tracing, and coordination. Scaling in can reduce usage-based charges, but not every associated cost disappears when compute resources are removed.

Horizontal scaling is not synonymous with automatic scaling or high availability. Engineers can add instances manually, and multiple instances can still share one failure domain. Distributing capacity across independent failure domains improves resilience, while auto scaling can restore or adjust capacity. A load balancer distributes traffic but does not, by itself, create additional application instances.

Key aspects of Horizontal Scaling

Horizontal scaling combines adjustable resource counts, parallel workload distribution, deliberate state management, and safe resource lifecycle controls.

Scale out and scale in

Increase capacity by adding processing units and reduce it by removing them. This differs from vertical scaling, which changes the capacity of an individual unit.

Elastic capacity adjustment

Auto scaling adjusts resource counts using demand signals or schedules within configured limits. Choose metrics that reflect workload pressure rather than assuming CPU utilization is always sufficient.

Workload distribution

Requests can be distributed through a load balancer, while asynchronous jobs can be distributed through a queue. Additional resources help only when useful work can run concurrently.

State management

Keep durable application data outside disposable processing instances where practical. Stateful workloads require deliberate replication, partitioning, or coordination strategies.

Safe resource lifecycle

Allow new resources to initialize before receiving traffic, and let departing resources drain connections or finish work. Account for startup delays when choosing scaling thresholds and minimum capacity.

Bottlenecks and failure domains

Test shared dependencies because adding application instances cannot remove every performance limit. Spread resources across appropriate failure domains when resilience is also required.

Cloud services for Horizontal Scaling

For a virtual-machine application, Amazon CloudWatch supplies demand measurements, Amazon EC2 Auto Scaling adjusts instance counts, and Elastic Load Balancing routes requests to healthy instances. Together, these services support elastic horizontal scaling, provided the application and its dependencies can handle parallel work.

For containers, Amazon ECS can adjust service task counts through ECS Service Auto Scaling; EC2-backed clusters also need sufficient host capacity. AWS Lambda manages execution-environment scaling without requiring engineers to manage a server fleet. Across these approaches, engineers must still configure limits, protect downstream dependencies, and monitor latency, errors, and resource utilization.

Amazon EC2 Auto Scaling image Amazon EC2 Auto Scaling

Changes the number of EC2 instances in an Auto Scaling group through scaling policies, schedules, or manual desired-capacity changes. Automatic capacity adjustments provide elasticity within configured minimum and maximum limits.

Open Amazon EC2 Auto Scaling →
AWS Lambda image AWS Lambda

Scales managed execution environments to process concurrent function invocations, subject to concurrency limits and scaling behavior. Downstream systems still need enough capacity to handle the resulting parallel requests.

Open AWS Lambda →
Amazon CloudWatch image Amazon CloudWatch

Provides metrics and alarms that can inform or trigger scaling actions. Engineers can monitor resource utilization and publish application-specific metrics to better match capacity to workload pressure.

Open Amazon CloudWatch →