An urgent patch on the only order management server means downtime: every restart is a gap in which the sales team sees an error instead of the order form. The company has already bought a second machine, but the application still runs only at the first one’s address, because nothing tells the traffic that an alternative exists.
What is missing is a load balancer. It accepts connections on a single address, spreads them across servers and stops sending traffic to the ones that do not respond, so any one of them can be switched off without interrupting users. The layer at which it works determines whether it only distributes connections or also reads requests, keeps sessions and terminates encryption. That last role makes it part of the security architecture, not just a performance component.
What is a load balancer and what exactly does it do?
A load balancer is a network component that accepts traffic destined for an application and distributes it across several backend servers according to defined rules. Microsoft defines load balancing as efficiently distributing incoming network traffic across a group of backend servers (Microsoft Learn, “What is Azure Load Balancer?”). The client knows only one address, a virtual IP address (VIP) or a DNS name pointing to it, and does not know which server handled its request.
For every connection or request, the load balancer settles three questions. Which servers are healthy right now? Which of them should receive this traffic? Does this client need to return to the server it used before? Health checks answer the first question, the algorithm the second and the session persistence mechanism the third.
The benefits follow directly from this model. The failure of one of several servers means a smaller pool rather than an unavailable application, a server can be taken out of the pool for an update, and another can be added without changing the address users know.
A load balancer does not speed up an individual request, and it will not fix an application that slows down because of an overloaded database. If every server relies on the same overloaded database, a second application server simply moves the bottleneck one floor down.
How does a layer 4 load balancer differ from a layer 7 one?
A layer 4 load balancer decides on the basis of IP addresses, ports and the transport protocol (TCP or UDP), while a layer 7 load balancer reads HTTP and HTTPS requests and can route traffic by URL path, headers or cookies. The numbering comes from the OSI model: layer 4 is transport, layer 7 is application.
Two services from the same cloud provider show the difference well. Azure Load Balancer operates at layer 4 of the OSI model and distributes TCP and UDP flows. Azure Application Gateway operates at the application layer and, as Microsoft puts it, unlike traditional load balancers that route traffic based on IP address and port, it makes decisions based on HTTP request attributes such as the URL path and host header (Microsoft Learn, “What is Azure Application Gateway?”). Requests containing /images can therefore go to different servers from those containing /video.
The difference also has a time dimension. NetScaler documentation describes load balancing granularity: for HTTP and HTTPS a server is chosen separately for each request, independently of TCP connections; for TCP-based protocols, for each new connection; and for UDP, per packet, after which a session lasts for a set period (NetScaler, “Load balancing algorithms”). A layer 7 load balancer can therefore spread the requests of one browser across several servers, whereas layer 4 keeps the whole connection on one.
Choosing a layer means choosing how much the load balancer should see. Layer 4 does not look into the content, so it needs no application certificates; Microsoft describes Azure Load Balancer as pass-through load balancing with ultra-low latency. Layer 7 gives content-based routing and rules for specific paths, but with HTTPS it requires TLS to be terminated on the load balancer, which means storing private keys there.
Key points:
- Layer 4 distributes connections by address and port, without visibility into content.
- Layer 7 reads HTTP requests and routes them by path, headers or cookies.
- Content-based routing of HTTPS traffic means decrypting it on the load balancer.
Which algorithms does a load balancer use to pick a server?
The algorithm decides which of the healthy servers receives the next connection or request, and the choice depends on whether the servers are identical and whether requests take similar amounts of time.
Round robin assigns servers in turn. In NetScaler’s description, the server at the top of the list is selected and, once it has taken a connection, moves to the bottom of the list; nginx uses this method by default when no other is specified (nginx, “Using nginx as HTTP load balancer”). It works well when servers have the same capacity and requests are short and similar.
Weights correct for unequal servers. In the example from the nginx documentation, a server with a weight of 3 receives three out of every five new requests, and the two remaining servers one each (nginx).
The least connections method sends traffic to the server that currently has the fewest. According to the nginx documentation, it distributes load more fairly when some requests take longer to complete, and in NetScaler it is the default algorithm (NetScaler). Variants based on response time choose the server that responds fastest.
Hashing algorithms compute a hash of the source address, destination URL or other fields and assign a server on that basis. The same client then always lands in the same place, but load distribution depends on how clients are distributed: an office that reaches the internet through a single NAT address may end up entirely on one server. A sensible starting point is least connections or round robin, changing the algorithm only when measurements show uneven load.
How does a load balancer check that a server is working?
A load balancer checks server state with health checks: tests after which an unhealthy server drops out of the pool until it starts responding correctly again. Azure Load Balancer uses health probes for this, so that traffic is sent only to healthy instances (Microsoft Learn).
Active tests are run by the load balancer itself: from checking whether a server accepts a connection on a port to an HTTP request that verifies the response code and content. The Radware Alteon product page lists layer 3, 4 and 7 health checks with content verification and custom scripts. Passive tests watch real traffic: after a failed exchange with a server, nginx marks it as failed and avoids it for a while. There, the max_fails parameter sets the number of consecutive unsuccessful attempts within fail_timeout and defaults to 1 (nginx).
A health check can test the wrong thing. A port test will confirm that the web server accepts connections even when the application behind it returns a 500 error because it has lost its database connection, and the load balancer will keep sending some users there. A better test calls a dedicated application endpoint that checks its dependencies. The opposite mistake is an over-sensitive test that, during a brief slowdown, removes several servers from the pool at once and pushes all the traffic onto the last one.
How do you keep a user’s session across several servers?
You keep a session in one of two ways: the load balancer always sends the client to the same server (persistence, sticky sessions), or the application keeps session state outside the server.
Persistence is handled on the load balancer side. In nginx it is provided by the ip-hash method: the client’s IP address is the key that determines the server, and that client’s requests always go there unless the server is unavailable. Application Gateway offers cookie-based session affinity (Microsoft Learn), which tells users apart even when many of them reach the internet through one address.
Persistence comes at a price: load distribution stops being even, a server failure still ends the sessions it held, and during a release pinned users stay on old servers longer than the plan assumes. That is why new applications are better designed to be stateless, with sessions in a database or a shared cache, leaving persistence for applications that cannot be rebuilt that way.
When does your company really need a load balancer?
Your company needs a load balancer when an application has to run on more than one server: for availability, capacity or maintenance without interrupting users.
The signals are concrete: an update needs a maintenance window negotiated with the business, the failure of one machine takes the service down for customers, TLS certificates have to be renewed on several servers separately, or the application has to run from two sites.
There are also situations where less is enough. The Radware Alteon product page states plainly that simple applications can make do with software such as nginx or HAProxy, and a fully cloud-based environment with the cloud provider’s native load balancer.
A load balancer is no substitute for preparing the application: if it stores data on the server’s local disk or cannot run as several copies at once, the decision starts with a conversation with its team, not with choosing a device. A load balancer deployed on its own is itself a single point of failure, which is why production deployments use pairs in high-availability mode. The active–standby and active–active modes of a specific product are covered in the article on load balancing with Radware Alteon.
How does a load balancer differ from an ADC, a reverse proxy and GSLB?
A load balancer is a function, while an ADC, a reverse proxy and GSLB are solutions that contain it or move it to a different scale.
An ADC (Application Delivery Controller) is a load balancer, usually working at both layer 4 and layer 7, with additional functions. The NetScaler (Citrix ADC) product page describes it as a solution that combines traffic load balancing, a WAF application firewall and application optimisation, and Radware Alteon as a controller with L4/L7 load balancing, TLS offloading and acceleration. An ADC is the point where applications are published, not just a traffic splitter.
A reverse proxy accepts requests on behalf of servers and forwards them. Every layer 7 load balancer is a reverse proxy in that sense, but not every reverse proxy distributes traffic, because it may simply sit in front of a single application; the nginx documentation describes load balancing as part of its reverse proxy implementation. More on intermediaries in traffic: the article on proxy servers.
GSLB (Global Server Load Balancing) distributes traffic between sites rather than servers. It works through DNS: it answers a query with the address of a healthy site and, after a failure, returns the address of the standby site, as the Radware Alteon product page describes. In Microsoft’s cloud a similar role is played by Traffic Manager, described in the documentation as DNS-based global routing.
How does a load balancer affect application cybersecurity?
A layer 7 load balancer that terminates TLS is the place where internet traffic is decrypted before it reaches the application, which makes it both an opportunity and a target for cybersecurity.
An opportunity, because it is the first point where you can look into the content of requests before they reach the application. Application Gateway combines TLS termination with integration with a web application firewall (WAF), and NetScaler, according to its product page, combines load balancing with a WAF in a single solution. A web application firewall analyses HTTP requests for attacks on applications; how it works is explained in the article on WAF and the WAF glossary entry.
A target, because the device stores the private keys of the published applications’ certificates and sees their traffic in plain text, so compromising it gives an attacker more than compromising a single server. The administrative interface should be reachable only from the management network, with multi-factor authentication, and the device software should be updated with the same discipline as other edge systems.
After TLS is terminated, traffic to the servers can travel in plain text or be encrypted again; Application Gateway also describes end-to-end encryption all the way to the backend servers. If the server segment is not isolated, plain-text traffic behind the load balancer moves the risk of eavesdropping inside the company.
Nor does a load balancer replace protection against DDoS. Even within one cloud, Microsoft separates these roles: layer 3 and 4 attacks are stopped by Azure DDoS Protection, and layer 7 attacks by the WAF on Application Gateway (Microsoft Learn).
How do you choose a load balancer for your application?
You start with the application, not the product: with the protocol it speaks, whether it holds state and where encryption should end.
| Design question | Layer 4 is enough when… | Layer 7 or an ADC is needed when… | Warning sign |
|---|---|---|---|
| Which protocol does the application speak? | the traffic is TCP or UDP other than HTTP (databases, mail, VPN) | the application is web-based and has several paths or domains behind one address | content-based routing planned for a protocol the load balancer does not understand |
| Where should TLS end? | encryption must reach the server without interruption | traffic must be inspected by a WAF or routed by URL | private keys on the load balancer with no plan to protect the management interface |
| Does the application keep sessions on the server? | the session lives outside the server, or one server handles the whole connection | cookie-based persistence is needed | IP-based persistence with clients behind a shared NAT |
| How should server health be checked? | a port test is enough because the service is simple | the application’s response and its dependencies must be checked | a health check that passes despite 500 errors |
| How many sites and environments? | one site or one cloud | several sites or a hybrid environment with GSLB | a DNS record with several addresses and no health checking |
| Who maintains the configuration? | rules are few and rarely change | rules change with every application release | no configuration owner and no configuration backup |
The answers do not have to be uniform across the company: the same ADC can handle TCP services at layer 4 and web applications at layer 7, each with its own rules and health checks. The form of deployment is a separate decision. The Radware Alteon product page lists hardware appliances, virtual machines, the cloud and containers (with an ingress controller for Kubernetes), and whatever the form, the team has to maintain the load balancer’s configuration as carefully as the servers behind it.
How can nFlo help you deploy a load balancer?
nFlo supplies and deploys the NetScaler (Citrix ADC) and Radware Alteon application delivery controllers. We run NetScaler deployments as projects: from requirements analysis, through configuration and integration with your existing infrastructure, to training your team.
Requirements analysis starts with the questions in the table above. Radware Alteon makes sense where you need L4/L7 load balancing with extensive health checks, GSLB between sites or integration with Radware DefensePro and AppWall protection, and NetScaler where load balancing should go hand in hand with a web application firewall.
Planning a second application server or replacing your controller? Let’s talk about the architecture before you decide on hardware.
What else should you know about load balancers?
Does a load balancer replace a network firewall?
No. A load balancer distributes traffic, while a firewall decides which traffic may pass. A WAF module in an ADC protects web applications, but it does not take over the firewall’s job at the network edge.
Is a load balancer worth it with only two servers?
Yes, if both serve the same application and availability or updates without downtime matter. The condition: one server must be able to carry all the traffic while the other is switched off.
Can DNS round robin replace a load balancer?
Only partly. Plain DNS does not check whether a server is up, so some clients will be sent to a machine that is not responding. GSLB combines DNS with health checks.
What is a virtual IP address (VIP)?
It is the address under which the load balancer publishes the application. The servers behind it can be added and replaced without changing the address users know.
What happens if the load balancer itself fails?
If it runs on its own, the application becomes unavailable even though the servers are running. That is why production deployments use a high-availability pair or cluster, and cloud deployments rely on the redundancy of a managed service, such as availability zones in Azure.
