Modern applications rarely run on a single server.
A production application may have:
This creates an important architectural problem:
How should incoming traffic be distributed across available application resources?
The answer is often load balancing.
A load balancer is a component that receives network traffic and distributes it across multiple backend servers or services according to defined rules.
A simplified architecture looks like this:
Internet
│
▼
DNS
│
▼
Cloud Load Balancer
│
┌────────────┼────────────┐
▼ ▼ ▼
Server A Server B Server C
│ │ │
└────────────┼────────────┘
▼
Application
Load balancing is therefore much more than simply “splitting traffic.”
Modern cloud load balancers can perform:
If you are building a cloud architecture from the beginning, it is useful to understand the broader principles explained in our Cloud Computing Explained guide.
Imagine a website running on a single server:
100 Users
│
▼
Server A
If traffic increases:
10,000 Users
│
▼
Server A
│
▼
Overloaded
The server may eventually experience:
A load-balanced architecture distributes the workload:
10,000 Users
│
▼
Load Balancer
│
┌───────────┼───────────┐
▼ ▼ ▼
Server A Server B Server C
The architecture can then scale horizontally.
Load balancing is closely connected to horizontal scaling.
Increase the resources of one server:
4 CPU / 16 GB RAM
↓
16 CPU / 64 GB RAM
This is often called scale up.
Add more servers:
Application
│
┌──────┼──────┐
▼ ▼ ▼
Server Server Server
A B C
This is called scale out.
Cloud architectures frequently combine both approaches.
For background on virtualized infrastructure, see Virtualization Explained.
The basic request flow is:
Client
│
│ Request
▼
Load Balancer
│
├── Health Check
│
├── Routing Decision
│
├── Backend Selection
│
▼
Application Server
│
▼
Response
│
▼
Load Balancer
│
▼
Client
The load balancer maintains knowledge about backend resources.
For example:
Backend Pool
Server A → Healthy
Server B → Healthy
Server C → Unhealthy
Server D → Healthy
The load balancer should avoid sending new traffic to Server C if its health-check configuration determines that it is unavailable.
A backend pool is a collection of servers or services that can process incoming traffic.
Example:
Load Balancer
│
Backend Target Group
│
┌───────────────┼───────────────┐
▼ ▼ ▼
Web Server 1 Web Server 2 Web Server 3
Depending on the cloud platform, backend targets may be:
This makes load balancing a central component of modern cloud-native architectures.
One of the most important concepts is the difference between Layer 4 and Layer 7 load balancing.
The distinction is based on the OSI networking model.
Our Computer Networking Explained guide provides the broader networking foundation needed to understand these layers.
Layer 4 operates primarily using transport-layer information.
Common protocols include:
A Layer 4 load balancer can make decisions using information such as:
Conceptually:
Client
│
│ TCP :443
▼
L4 Load Balancer
│
├── Server A
├── Server B
└── Server C
The load balancer does not necessarily need to understand the application-level HTTP request.
L4 load balancing can provide:
It is particularly useful for workloads where application-level inspection is unnecessary.
Examples can include:
Layer 7 operates at the application layer.
For web applications, this commonly means HTTP or HTTPS.
A Layer 7 load balancer can inspect request information such as:
For example:
GET /api/users
could be routed differently from:
GET /images/logo.png
Architecture:
HTTPS
│
▼
L7 Load Balancer
│
┌──────────┼──────────┐
│ │ │
▼ ▼ ▼
/api /shop /static
│ │ │
▼ ▼ ▼
API Pool App Pool CDN/Pool
This enables much more intelligent application routing.
| Feature | L4 | L7 |
|---|---|---|
| OSI layer | Transport | Application |
| TCP | Yes | Usually supported through HTTP/TLS-aware services |
| UDP | Common | Service-dependent |
| HTTP awareness | No/limited | Yes |
| URL routing | No | Yes |
| Host routing | No | Yes |
| Cookie routing | No | Yes |
| Processing overhead | Lower | Higher |
| Application awareness | Low | High |
| Typical use | Network traffic | Web/API applications |
Neither approach is universally correct.
The architecture should match the traffic type and application requirements.
A load balancer needs a method for selecting a backend.
Common algorithms include:
The simplest model is:
Request 1 → Server A
Request 2 → Server B
Request 3 → Server C
Request 4 → Server A
Request 5 → Server B
Request 6 → Server C
This works well when backend servers have relatively similar capacity and workload characteristics.
Suppose:
Server A = weight 5
Server B = weight 3
Server C = weight 2
The load balancer can distribute more traffic to Server A.
This is useful when:
Instead of simply rotating servers, the load balancer sends traffic toward servers with fewer active connections.
Example:
Server A → 200 connections
Server B → 80 connections
Server C → 120 connections
A new connection may therefore be directed toward Server B.
This can be useful when connections have significantly different durations.
Some applications historically depend on users returning to the same backend server.
A simplified model is:
Client IP
│
▼
Hash Function
│
▼
Backend Selection
Another technique is session affinity, sometimes called sticky sessions.
For example:
User A ─────────► Server A
User A ─────────► Server A
User A ─────────► Server A
This can simplify applications that store session state locally.
However, stateless application architecture is generally easier to scale.
A stateless application does not depend on local memory on a particular server for user session state.
Instead:
Load Balancer
│
┌──────────┼──────────┐
▼ ▼ ▼
Server A Server B Server C
│ │ │
└──────────┼──────────┘
▼
Shared State
Shared state could be stored in:
This architecture allows traffic to move more freely between backend servers.
Consider:
Request 1 → Server A
Request 2 → Server B
Request 3 → Server C
If the application requires every request from the same user to return to Server A, scaling becomes more difficult.
A stateless application allows:
Request 1 → A
Request 2 → B
Request 3 → C
Request 4 → A
without breaking application state.
This is especially useful with:
One of the most important load-balancer functions is health checking.
A load balancer may periodically test:
GET /health
and expect:
HTTP 200 OK
If a backend repeatedly fails:
Server B
│
▼
Health Check
│
▼
Failed
│
▼
Removed from Traffic
Health checks prevent the load balancer from continuously sending traffic to unhealthy resources.
Health checks may operate at different levels.
Tests whether a TCP connection can be established.
Can I connect to port 443?
Tests an HTTP endpoint.
GET /health
The endpoint can verify dependencies.
For example:
Application
│
├── Database
├── Cache
└── Required Service
But deep health checks must be designed carefully.
If every minor dependency failure marks the entire application unhealthy, a temporary dependency problem can remove every backend from service.
A good health endpoint might return:
{
"status": "healthy",
"version": "2.4.1"
}
But a production system might distinguish between:
/liveness
/readiness
Answers:
Is the process alive?
Answers:
Can this instance safely receive production traffic?
This distinction is particularly important in containerized and orchestrated environments.
Cloud load balancers can often terminate TLS connections.
Without TLS termination:
Client
│ HTTPS
▼
Load Balancer
│ HTTPS
▼
Application
With TLS termination:
Client
│ HTTPS
▼
Load Balancer
│ HTTP or HTTPS
▼
Application
The second design reduces encryption work on backend servers, but whether HTTP is acceptable internally depends on the security architecture.
For sensitive workloads, encryption may remain enabled between the load balancer and backend.
A stronger architecture can use:
Client
│
│ HTTPS
▼
Load Balancer
│
│ HTTPS
▼
Application
This provides encryption across both network segments.
Certificate management becomes an important operational concern.
A Layer 7 load balancer can route traffic according to the hostname.
For example:
api.example.com
│
▼
API Pool
shop.example.com
│
▼
Shop Pool
admin.example.com
│
▼
Admin Pool
This allows multiple applications to share infrastructure.
Traffic can also be routed according to URL paths.
Example:
example.com/api/*
↓
API Servers
example.com/images/*
↓
Static Servers
example.com/app/*
↓
Application Servers
This pattern is extremely useful for modern web architectures.
Some advanced application load balancers can route based on HTTP headers.
For example:
X-API-Version: v2
could be directed toward a version-specific backend.
This can support:
Load balancing can support gradual software releases.
For example:
100% Traffic
│
▼
Load Balancer
/ \
/ \
95% 5%
│ │
▼ ▼
Version 1 Version 2
The new version can receive a small percentage of traffic.
If monitoring indicates problems, traffic can be reduced or removed.
This is an important DevOps deployment pattern.
Another deployment strategy is:
Load Balancer
│
┌─────┴─────┐
▼ ▼
Blue Green
Version 1 Version 2
Initially:
100% → Blue
After validation:
100% → Green
If rollback is necessary:
100% → Blue
This can make deployment rollback relatively straightforward.
Load balancing becomes particularly powerful when combined with autoscaling.
Architecture:
Users
│
▼
Load Balancer
│
┌──────────┼──────────┐
▼ ▼ ▼
Server Server Server
│ │ │
└──────────┼──────────┘
▲
│
Autoscaling
│
┌─────┴─────┐
▼ ▼
Add Node Remove Node
If traffic increases:
Traffic ↑
↓
CPU/Request metrics ↑
↓
New instances
↓
Load balancer registers them
If traffic decreases:
Traffic ↓
↓
Capacity requirement ↓
↓
Instances removed
This is one of the fundamental patterns behind elastic cloud infrastructure.
A resilient cloud architecture should avoid depending on one failure domain.
Conceptually:
Load Balancer
│
┌───────────┼───────────┐
▼ ▼ ▼
Zone A Zone B Zone C
│ │ │
Server Server Server
If Zone A experiences a failure, traffic can continue toward healthy resources elsewhere.
The exact implementation differs between providers.
Global applications may require multiple geographic regions.
Example:
Global Users
│
▼
Global Routing
/ \
/ \
▼ ▼
Region Europe Region America
│ │
▼ ▼
Load Load
Balancer Balancer
│ │
App Pool App Pool
Traffic can be distributed according to:
This is commonly called global load balancing or global traffic management, depending on the provider.
| Feature | Regional | Global |
|---|---|---|
| Scope | One region | Multiple regions |
| Primary purpose | Local distribution | Geographic distribution |
| Complexity | Lower | Higher |
| Failover | Zone-level | Region-level |
| Latency optimization | Limited | Geographic |
| Disaster recovery | Moderate | Stronger potential |
| Cost | Usually lower | Usually higher |
Global architecture introduces additional considerations such as:
DNS often participates in global traffic distribution.
Conceptually:
User
│
▼
DNS
│
├── Region A
├── Region B
└── Region C
For example, DNS policies can be based on:
However, DNS-based failover has limitations because DNS responses may be cached according to TTL behavior.
Therefore, DNS and load balancing should be designed together.
Load balancers depend heavily on network architecture.
Important components include:
Our Cloud Networking Explained guide covers these concepts in detail.
A simplified architecture is:
Internet
│
▼
Public Load Balancer
│
▼
Private Subnet
│
▼
Application Servers
This separates public ingress from private application resources.
A load balancer is not automatically a complete security system.
You may still need:
For network-layer protection, see Firewalls Explained.
For the broader security architecture, see Network Security Basics.
These concepts overlap but are not identical.
A reverse proxy receives requests on behalf of backend servers.
Client
│
▼
Reverse Proxy
│
▼
Backend
A load balancer can function as a reverse proxy while also distributing traffic across multiple backends.
Modern cloud application load balancers often combine:
These services can also overlap.
An API gateway may provide:
A load balancer primarily focuses on traffic distribution and availability.
Some cloud platforms combine or integrate these capabilities.
Suppose Server B needs to be removed.
Immediately terminating it could break active connections.
Connection draining provides a safer process:
Server B
│
▼
Stop New Connections
│
▼
Existing Requests Complete
│
▼
Remove Server
This is especially useful during:
Applications should support graceful shutdown.
For example:
SIGTERM
│
▼
Stop accepting new requests
│
▼
Finish active requests
│
▼
Close connections
│
▼
Shutdown
This works together with load-balancer draining.
Without graceful shutdown, even a sophisticated load-balancing architecture can cause avoidable request failures during deployments.
If an application requires sessions, there are several approaches.
User → Server A
Server A ─┐
Server B ─┼──► Redis / Database
Server C ─┘
For example, an application can use signed tokens so that session state does not depend entirely on a specific server.
The correct model depends on the application’s security and state-management requirements.
Load balancing is not limited to HTTP servers.
Some database systems can use load-balancing patterns for read workloads.
Example:
Application
│
▼
Database Routing
/ \
▼ ▼
Primary Read Replica
Writes may go to the primary while read queries are distributed among replicas.
However, applications must account for:
For the database architecture itself, see our Cloud Databases Explained guide.
Traditional HTTP request/response traffic is relatively simple.
WebSockets create long-lived connections:
Client
│
│ Persistent Connection
▼
Load Balancer
│
▼
Server
The load balancer must support the protocol and maintain the connection appropriately.
Applications may also need:
Not all applications use HTTP.
UDP can be important for:
Layer 4 load balancing is often relevant for these workloads.
The provider’s specific UDP support, timeout behavior, health checks, and regional capabilities must be verified against current documentation.
Load balancing can improve resilience by distributing legitimate traffic across infrastructure.
But a load balancer alone is not a complete DDoS defense.
A layered architecture might include:
Internet
│
▼
DDoS Protection
│
▼
WAF / Security Layer
│
▼
Load Balancer
│
▼
Application
This is an example of defense in depth.
Rate limiting controls how many requests a client can make within a defined period.
For example:
Client
│
▼
100 requests/minute
│
▼
Allowed
Excessive requests may be rejected or delayed.
Rate limiting can protect against:
It should be combined with authentication and broader security controls.
A production load balancer should be monitored.
Important metrics can include:
A useful model is:
Observability
│
┌────────────┼────────────┐
▼ ▼ ▼
Metrics Logs Traces
│ │ │
└────────────┼────────────┘
▼
Troubleshooting
For broader monitoring and security-event correlation, see SIEM Explained.
When an application behind a load balancer fails, use a structured process.
Client
│
▼
DNS
│
▼
Load Balancer
│
▼
Backend
│
▼
Application
│
▼
Database
Test each layer separately.
Verify that the domain resolves to the expected endpoint.
Check:
Determine whether backend targets are marked healthy.
Where appropriate, test the application without the load balancer.
Ensure the load balancer can communicate with backend resources.
Look for:
Often indicates that the proxy/load balancer could not obtain a valid response from the backend.
Possible causes include:
Can occur when no healthy backend is available or the service is otherwise unable to serve the request.
Usually indicates that the upstream service did not respond within the configured timeout.
These status codes do not identify one universal root cause.
Always inspect logs and backend health information.
Before production deployment:
[ ] TLS configured
[ ] Certificates managed
[ ] Backend access restricted
[ ] Health checks configured
[ ] Security groups/firewall rules reviewed
[ ] Administrative interfaces protected
[ ] Rate limiting considered
[ ] DDoS protection evaluated
[ ] Logging enabled
[ ] Monitoring enabled
[ ] Alerts configured
[ ] Backend encryption evaluated
[ ] Access policies reviewed
[ ] Failover tested
Load balancing should be treated as part of the overall security architecture, not as a standalone security mechanism.
AWS provides multiple load-balancing capabilities through Elastic Load Balancing.
The major load-balancer families include:
AWS documents Application Load Balancers as operating at the application layer and supporting features such as host- and path-based routing, while Network Load Balancers are designed for high-performance Layer 4 traffic. (docs.aws.amazon.com)
A simplified AWS architecture:
Internet
│
▼
AWS Load Balancer
│
┌────────┼────────┐
▼ ▼ ▼
EC2 EC2 EC2
AWS load balancing can integrate with autoscaling and multiple availability zones.
Microsoft Azure provides several traffic-distribution services for different network and application requirements.
Azure Load Balancer is primarily associated with Layer 4 traffic distribution, while Azure Application Gateway provides application-layer capabilities such as HTTP routing and TLS termination.
Microsoft’s documentation distinguishes these services according to their traffic and application-layer roles. (learn.microsoft.com)
Conceptually:
Internet
│
▼
Azure Traffic Service
│
▼
Application / VM Pool
For broader Azure architecture, compare it with AWS vs Azure vs Google Cloud.
Google Cloud provides managed load-balancing services supporting different traffic patterns, including HTTP(S), TCP, SSL, and UDP workloads.
Google describes Cloud Load Balancing as a managed service capable of distributing traffic across backends and supporting global and regional architectures. (cloud.google.com)
A conceptual global architecture:
Users
│
▼
Global Load Balancer
/ \
▼ ▼
Region A Region B
│ │
▼ ▼
Backends Backends
The providers use different product names and implementation details.
| Area | AWS | Azure | Google Cloud |
|---|---|---|---|
| L4 capabilities | Yes | Yes | Yes |
| L7 capabilities | Yes | Yes | Yes |
| Global options | Yes | Yes | Yes |
| Health checks | Yes | Yes | Yes |
| TLS termination | Yes | Yes | Yes |
| Autoscaling integration | Yes | Yes | Yes |
| Multiple traffic models | Yes | Yes | Yes |
The table is intentionally architectural rather than product-specific because individual capabilities and limits vary by service and evolve over time.
For a broader provider comparison, see AWS vs Azure vs Google Cloud.
A mature cloud architecture might look like:
Internet
│
▼
DNS
│
▼
Global Traffic Layer
│
▼
Regional Load Balancer
│
┌──────────────┼──────────────┐
▼ ▼ ▼
Zone A Zone B Zone C
│ │ │
▼ ▼ ▼
App 1 App 2 App 3
│ │ │
└──────────────┼──────────────┘
▼
Cache
│
▼
Cloud Database
│
▼
Backups
Security surrounds the architecture:
Identity
│
┌──────────┼──────────┐
▼ ▼ ▼
WAF Firewall TLS
│ │ │
└──────────┼──────────┘
▼
Load Balancer
This architecture supports:
A production load-balancing strategy should follow several principles.
Assume individual instances will fail.
Do not route traffic blindly.
Where practical, avoid local session dependencies.
Load balancing does not solve slow applications automatically.
Combine connection draining with application-level shutdown handling.
Do not assume internal traffic is automatically safe.
A theoretical failover mechanism is not enough.
Ensure new instances become healthy before receiving production traffic.
Global traffic distribution and cross-region architectures can increase network costs.
Complex routing becomes difficult to troubleshoot without documentation.
Before deployment:
Architecture
[ ] Backend pools defined
[ ] L4/L7 requirement identified
[ ] Scaling model defined
[ ] Availability zones considered
[ ] Regional strategy defined
Routing
[ ] Routing rules documented
[ ] Health checks configured
[ ] Timeouts reviewed
[ ] Connection draining configured
[ ] Session strategy defined
Security
[ ] TLS configured
[ ] Firewall rules reviewed
[ ] Backend access restricted
[ ] DDoS strategy evaluated
[ ] Logging enabled
Operations
[ ] Monitoring configured
[ ] Alerts configured
[ ] Failover tested
[ ] Deployment strategy tested
[ ] Capacity planning completed
Cloud load balancing distributes network or application traffic across multiple backend resources hosted in cloud infrastructure.
L4 operates primarily at the transport layer using TCP/UDP information, while L7 can understand application-layer protocols such as HTTP and make routing decisions using paths, hosts, headers, and other request information.
It can improve scalability and resource utilization, but it does not automatically make an inefficient application faster.
Load balancing can contribute to high availability by distributing traffic across multiple healthy resources, but the complete architecture must also address failure domains, application health, databases, networking, and recovery.
A health check is a mechanism used to determine whether a backend resource should receive traffic.
Session affinity attempts to keep a client’s requests associated with the same backend resource.
No. Stateless applications can often distribute requests more freely and scale more easily.
TLS termination means the load balancer handles the client’s encrypted TLS connection and then forwards traffic to the backend according to the configured architecture.
Some database architectures can use traffic-distribution mechanisms for read workloads, but database consistency, replication lag, and transaction requirements must be considered.
Global load balancing distributes application traffic across geographically separated regions or locations according to policies such as latency, geography, capacity, or health.
Cloud load balancing is one of the fundamental building blocks of modern distributed infrastructure.
A load balancer can sit between users and application resources while providing:
But the load balancer itself is only one component.
A reliable cloud architecture connects:
DNS
↓
Traffic Management
↓
Load Balancer
↓
Application
↓
Cache
↓
Database
↓
Backup / Disaster Recovery
while security controls operate across the entire architecture.
The most important architectural decision is not simply choosing a load-balancer product. It is understanding the workload and selecting the appropriate combination of:
When these components are designed together, cloud load balancing becomes a foundation for scalable, resilient, and production-ready applications.
Continue the Cloud & DevOps cluster with:
Introduction Border Gateway Protocol (BGP) is the routing protocol used to exchange network reachability information…
Introduction A Linux server can experience connection failures even when its network interface is working…
Introduction TCP retransmissions are an important indicator of network reliability and performance. When a Linux…
Open Shortest Path First (OSPF) is a link-state routing protocol widely used in enterprise networks…
Group Policy is one of the most important management features in Windows Server Active Directory…
Windows DNS servers play an essential role in Active Directory environments, allowing computers, servers, applications,…