Jon Totham



An introduction to load balancing - part 1

This is part one of a four part article on what load balancing is and what you might be able to do with it.

The most common use for a load balancer is to improve the performance and reliability of a server environment by distributing the workload across multiple servers.

At Wirehive we have built our own load balancer appliance which is based HAProxy. This is a well know piece of open source software and is used by many well-known environments, including: GitHub, Imgur, Twitter and Instagram.

Load balancer terms

There are many different terms used in load balancing but the main ones you will need to understand are frontends, backends, servers and Access Contol Lists (ACLs).


The frontend of the load balancer is where new inbound connections are received and also defines which backend the requests are forwarded too.

The following are defined in the frontend section of a HAProxy configuration:

  • The mode the frontend is running in.

  • A set of IP addresses and a port to listen on (e.g. *:80, *:443, etc.)

  • A default_backend rule, which defines the default backend to use when not otherwise specified by an ACL.

  • ACL’s when more complex systems are being built

Here is an example of frontend listening on port 80 defaulting to the cms-backend with admin requests being diverted to the admin-backend.

frontend http

        mode           http

        bind            :80

        default_backend backend-cms

        acl req_admin path_end /admin.php

        use_backend backend-admin if req_admin

The mode http line specifies if you want to use layer 7 proxying instead of mode tcp (which would use layer4). The differences between the two are explained in more detail in the next blog article however in order to use ACL’s and the other more powerful features of HAProxy you need to be using layer 7 mode http.

Access control lists (ACLs)

When looking at HAProxy load balancing, ACLs can be used to select a backend based on the result of a test. The test can be a simple thing like does the requested url end with /admin.php or can be built up with regex to match multiple conditions at the same time.

One simple use of ACLs in this way is to directed traffic to different backends based on pattern-matching like in the below example.

        acl req_admin path_end /admin.php

        use_backend backend-admin if req_admin

This ACL will be matched if the http request from the user ends with /admin.php then any requests matching the ACL will be sent to the backend-admin backend.


A backend is a set of servers that receives requests forwarded on by the frontend. In a very basic form, a backend can be defined by:

  • which load balance algorithm to use

  • a list of servers and ports

A backend can contain one or many servers and my also specify weights, check commands, backup entries.

Here is an example of a backend configuration to go with the frontend example above:

backend backend-cms
balance roundrobin
server web1 check
server web2 check

backend backend-admin
balance roundrobin
server admin1 check

In this example the balance line specifies the load balancing algorithm used for the backend and the check option at the end of the server directives specifies that health checks should be performed on those backend servers. More details on both to come in future articles.

Now we have covered the key terms required to understand the applications of load balancing. In the next article the focus will be on types of load balancing.