You don’t have to be a famous actor or musician to get a high number of website visits. But when you do, you want to be sure that your website can handle the huge spike in visitors. If you don't account for this, then chances are your website will be knocked off its feet when the first spike in traffic hits.

The good news is, there's a very easy way to manage large traffic volumes as efficiently as possible. If you want one of the most effective solutions for maximising server performance, then you should invest in a load balancer.

What is a load balancer?

A load balancer is a piece of software or hardware that's capable of distributing web traffic across multiple servers to simulate various visitor quantities to a given site.

By efficiently spreading this workload across multiple physical or virtual machines in a cluster, a load balancer works to maximise the availability of a website or application for maximum usage. Not only that, but load balancing is also an excellent way to increase performance by maximising network throughput, the rate at which data can be successfully transferred.

How do load balancers work?

Once installed, a load balancer will sit between a cluster of two or more servers and the public internet. When it receives requests from the internet, such as from a web browser, it directs these requests to the appropriate server (usually the one with the most capacity available).

By regulating traffic across several servers, a load balancer prevents individual machines from becoming swamped with requests. This ensures services are available for more concurrent users, with faster loading times and a more consistent experience for everyone. Even if individual servers are put under pressure or taken offline altogether due to web traffic spikes, load balancing ensures that there'll always be at least one server available for use.

But a load balancing server doesn't just provide increased availability for end-users. They also offer better flexibility on the backend. With a load balancing server, you can perform maintenance and updates on servers in your cluster, or even take individual machines offline. And you do it all safe in the knowledge that availability will always be maintained through other active servers.

Load balancing and persistence

When discussing persistence with load balancing, ‘persistence’ refers to the information that needs to be carried over to complete multiple requests – like a user filling up their online cart on Amazon and then logging in to make their purchase.

When a user visits a site and makes a request, some session information (like the items in their shopping cart) might be stored in their browser. But if the session information is stored on a server (like their login request details), then this can become a problem when a load balancing server is introduced.

If a user’s requests initially connect to one server that stores session information locally but subsequent requests go to other servers in the cluster, the session information may no longer be available as it's now divided between multiple separate servers. This means a user is prevented form completing their request.

To get around this issue and ensure a consistent user experience, a load balancing server can be set up to make sure that each session is handled by a single server, instead of redirecting the user to a new server for each request. Alternatively, other persistence solutions include shared storage and databases that can be accessed by every server in the cluster to instantly pull the information a user requires.

Of course, if persistence isn’t required, there’s no need to implement it. But for complex, interactive websites such as online shops, persistence is a business-critical feature, one that load balancing can help streamline if implemented correctly.

Here at Fasthosts, our CloudNX platform can enable persistence for up to 1200 seconds, ensuring each client will have all their requests directed to the same server within the set time period.

Different load balancer types

The end goal of any load balancer is to distribute traffic efficiently amongst its servers. There are several different procedures it can follow to achieve this, but the two most widely implemented load balancing algorithms are known as ‘round robin’ and ‘least connections’.

Round robin is the simplest and most common load balancing technique. In a round-robin setup, the load balancer runs through a sequence of servers, handing off each new request to the next server on the list. This ensures that requests are distributed evenly across the cluster at all times.

Unfortunately, while the round robin method is easy to implement, it can have drawbacks. Even if each server in the cluster is assigned the same number of requests, persistence means that some clients may stay connected to a particularly overworked server for longer, leading to an even higher workload for that machine.

Least connections, on the other hand, uses a procedure that looks for the server with the lowest number of current connections and hands that one the newest request.

By taking the current load of each server into consideration, least connections operates as a more effective load balancer algorithm in clusters where clients tend to stay connected to a particular server for longer.

When you use the Fasthosts CloudNX platform, you can choose between both load balancer types for your setup. Just select your load balancing algorithm of choice when you create a new load balancer or edit existing load balancers to change the load balancing procedure at any time.

Load balancing and security

As well as boosting availability and performance, load balancing can also provide security advantages. A load balancer can act as a gatekeeper between your servers and the public internet, preventing clients from contacting backend servers directly where all the vital data is stored.

This can be achieved by configuring your load balancer to forward ports. For example, by taking incoming HTTP requests on the standard port (80) then forwarding them on to a custom port on a server.

Port forwarding can be useful if you have an application running on a custom port, and you don’t want to expose it to the public internet. It’s a simple case of setting the app to only accept connections from your load balancer.

What is a load balancing router?

Load balancers aren't just for use in the world of business. Investing in a load balancing router means you can easily get the benefits of load balancing for your own personal use if you have more than one internet connection.

A load balancing router works by taking the various incoming internet connections and then dividing their web traffic equally across all connections. This takes the strain off your router and helps to deliver a better overall browsing experience for those using the connections.

Should I use a free load balancer?

There are several different types of free load balancers currently available. However, much like with any kind of free software, a free load balancer comes with some big drawbacks.

First and foremost, free load balancers tend to have fairly limited scalability, meaning you likely won't be able to expand your server count without paying. On top of this, free load balancers are also likely to lack various features or choices available to users working with a paid load balancer.

With all that being said, a free load balancer is a great way to begin experimenting with load balancing as a concept and allows you to get to grips with how it works.

While not free, the Fasthosts CloudNX platform comes with a fully configurable load balancer for use with our Cloud Servers. Build your own custom cloud infrastructure with the performance and resilience of load balancing and make use of our full range of enterprise features. Bets of all, you only need to pay for what you use.

And it's not just our cloud servers that offer load balancing options. Our Web Hosting also has intelligent load balancing built into the platform, ensuring peak performance even under heavy load or during maintenance. We also offer Website Builders and Domain Name services for those looking to begin building their online presence.

Get in touch with our experts today to find out more or head over to the Fasthosts blog for more detailed articles and in-depth guides on tech and the internet.