Sub topic 8
Hardware, software and cloud load balancers
This chapter assumes you know what a load balancer does, the difference between Layer 4 and Layer 7, and how to read a basic NGINX or HAProxy configuration. Here you will compare the three ways to run a load balancer and choose between them.
Three deployment types
The balancing logic is the same in all three. What changes is who owns the machine, how you scale it, and how you pay for it.
- Hardware load balancers are dedicated appliances from vendors such as F5 and Citrix. They use purpose-built chips (ASICs) to handle very high connection rates and TLS work.
- Software load balancers are programs you run on ordinary servers, virtual machines or containers. NGINX, HAProxy and Envoy are common examples.
- Cloud load balancers are managed services such as AWS Elastic Load Balancing, Google Cloud Load Balancing and Azure Load Balancer. The provider runs and scales them for you.
Hardware appliances
An appliance gives you predictable, high throughput in one box. Vendors also provide support contracts and built-in features such as web application firewalls.
The costs are real:
- The purchase price is high, and you often pay extra for feature licenses.
- Capacity is fixed. You buy for peak load and pay for it all year.
- You must rack, cable and patch the device yourself.
- Automation is often weaker than with software tools, though most vendors now offer APIs.
Appliances still make sense in data centers with very large, steady traffic, or where a team already depends on a vendor's feature set.
Software load balancers
Software is the most flexible choice. The configuration is plain text, so you can keep it in version control, review changes, and deploy it with the same tools as your applications.
The NGINX example earlier in this tutorial shows this style:
upstream app {
least_conn;
server 10.0.0.11:8080 weight=3 max_fails=3 fail_timeout=30s;
server 10.0.0.12:8080 max_fails=3 fail_timeout=30s;
server 10.0.0.13:8080 backup;
}
server {
listen 80;
location / {
proxy_pass http://app;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}You choose the hardware, the operating system and the version. You can run a copy per team or per service, or run one inside a Kubernetes cluster. The trade-off is that you own everything: patching, capacity planning, kernel tuning and high availability. A single software instance is limited by the server it runs on, so a very large site needs several instances in front of it.
Cloud load balancers
A cloud load balancer removes most operational work. You create it with an API call or a console, point it at a target group, and the provider handles scaling and redundancy across zones.
Typical features include:
- Health checks and TLS certificate management.
- Integration with autoscaling groups, so new instances join the pool automatically.
- Separate products for Layer 4 and Layer 7. In AWS, the Network Load Balancer works at Layer 4 and the Application Load Balancer at Layer 7.
The limits are less control and some lock-in. You can only use the algorithms, headers and timeouts the provider exposes. Pricing usually combines an hourly charge with a usage charge, so cost grows with traffic. Configuration also does not move easily to another provider.
Choosing between them
| Factor | Hardware | Software | Cloud |
|---|---|---|---|
| Upfront cost | High | Low | None |
| Scaling | Buy a bigger box | Add instances | Automatic |
| Control | High, vendor-defined | Full | Limited to provider options |
| Operations burden | High | Medium to high | Low |
| Portability | Low | High | Low |
Use these questions to decide:
- Do you already run in a public cloud? If so, start with its managed load balancer.
- Do you need behavior the managed service cannot provide, such as custom routing logic or a specific algorithm? Use software.
- Do you need to run the same setup on-premises and in several clouds? Software is the most portable.
- Do you have a large, steady data center load and an existing vendor relationship? Hardware may be cost-effective.
Exercise
Your team runs a web application on AWS with traffic that varies ten-fold between night and day. You have no staff dedicated to infrastructure. Which load balancer type fits best, and why? Name one situation that would make you add a software load balancer.
Show answer
A cloud load balancer fits best. It scales automatically with the changing traffic, spreads across zones for availability, and needs little operational work. You would add a software load balancer, such as Envoy or HAProxy, if you needed custom routing or a balancing algorithm the managed service does not offer.
Exercise
List two costs of choosing a hardware load balancer instead of a software one.
Show answer
Any two of: high upfront price and feature licenses, fixed capacity that you must buy for peak load, manual racking and patching, and weaker portability and automation.