What Are Load Balancers?
Take the strain off your VPS: split the load!
As your website or service increases in popularity, it’s possible that your VPS or server will slowly become overloaded from the increase in visitors, leading to a decrease in efficiency. Whilst the traditional solution is to upgrade the server when it reaches capacity, eventually you’ll find that the cost of upgrading may outweigh the benefits…
The solution? Split the workload.
An alternate solution is to split the work between multiple servers, but this is only advisable once you know how to manage the workloads between the servers.
This is where a load balancer comes in.
A load balancer can be built from a server or can be a dedicated hardware appliance. Its purpose is to monitor the load on multiple servers, directing incoming traffic to the server with the least load. A side benefit of this can be that if one system in the group fails then the load balancer will automatically direct load away from that system and on to the remaining working ones, keeping your services online.
So how does this work?
There are a number of methods to achieve this, one common one being to set your DNS so your site or service appears to come from the load balancer’s IP address. That way all incoming requests for your site or service are directed to the load balancer, and the load balancer can then decide which is the best destination before forwarding on the request. Following this, the server’s response will be sent back to the load balancer, which then replies to the customer.
Should the server handling the user request need to store session data, the load balancer can be configured with persistence settings. This will ensure that subsequent requests from a specific user will be directed to the server that has previously handled their requests for set time duration, thus eliminating the need to replicate session data for users across the cluster of servers that are sitting behind the load balancer.
How does a load balancer know which server is the best fit for an incoming connection?
Most commonly, a load balancer will use the Round Robin method to decide which server is the right place to route an incoming connection. This basic method involves the load balancer methodically working through the list of servers, assigning new connections to the next server in the list until it reaches the end, beginning to distribute connections to servers at the top of the list again in a cyclic structure. This unfortunately doesn’t take into account the fact that the servers may have differing loads that may affect response times from specific servers. An alternate (albeit more complicated) setup is to have the load balancer also monitor the loads on the various servers and choose to direct new requests to the server with the lowest load first.
Things to remember:
Setting up a load balanced solution isn’t as simple as just configuring the load balancer and setting up duplicate of your existing server. There’s work to be done in making sure that your website files are duplicated between your servers and your database is duplicated. Sometimes the databases will be moved onto their own servers, allowing a group of servers to handle the clients that will then communicate with a smaller cluster of servers that manage the databases.
Contact our support team for advice on setting up a load balancer and how best to distribute workload between your Virtual Private Servers.