Load balancing in OnApp clouds – part 1 – LB clusters
Reports show that there are almost 4 billion users on the Internet. The number of Internet users has grown steadily at approximately 200 million per year, over the past decade, and will continue to grow at that rate.
So, if you are hosting any sort of Web service or content it is important that you have the appropriate cloud resources available, not just for your current users, but for the growing number of potential users coming online every day.
OnApp clouds include a Load Balancer feature that allows you to prepare for potential growth and meet high traffic demands for web services. There are two types of load balancer options available within OnApp: Load Balancing Clusters and Autoscaling Clusters. Both of these balancing options can be used to ensure your service is always available and has the resources available to meet high demands. In this post, I’ll explain how Load Balancing clusters can help you – and next time, we’ll cover Autoscaling Clusters.
Load Balancing Clusters
A Load Balancing cluster is a cluster of identical virtual machines or nodes that provide the same service. These machines have a Load Balancer at the head, that takes all of the incoming traffic and equally distributes the traffic to the different machines in the cluster.
The end user accesses the service with a single hostname, but the service will come from the entire cluster of nodes rather than a single end point. This helps with overall availability: if one node fails, traffic will automatically be routed to another node in the cluster. You can add and remove nodes to the cluster as demand requires.
Let’s run through how this works in OnApp clouds.
1. Create Nodes
First you will want to create a virtual machine that is providing a service. The service can be anything that a server would be used for, such as a website, database, etc. In this example I am creating two nodes, named lbnode1 and lbnode2. I am giving these nodes the same hostname of lbdemo.onapp.demo.
Instructions for creating a virtual machine in OnApp can be found at https://docs.onapp.com/agm/latest/appliances/virtual-servers/create-virtual-server
Once these nodes are online, I set up a simple website on each node, that is identical on each node. For testing I have changed the text on node 2 to show which node the requests are being served by. In normal use, of course, each node will have identical content:
2. Create Cluster
Once the initial nodes are ready to go, you now need to set up a Load Balancer cluster. The cluster defines which port or ports the balancer will be routing traffic for, and the hostname to be used by the cluster. Since our example balancer will be serving a website, we are going to use the standard http and https protocol ports 80 and 443 to assign to the cluster.
More information on setting up a load balancing cluster in OnApp can be found at https://docs.onapp.com/agm/latest/appliances/load-balancers/create-load-balancer-cluster
3. Add nodes
On the next page of the Add Balancer wizard, we need to select the nodes to assign to this cluster. Locate the hostname of the node you created earlier, and click on the Add Node button. Repeat this for each node you are adding to the cluster. Once all nodes have been added, click on the Save Button.
4. That’s it – LB created!
Congratulations! You have created a fully functional Load Balancer. Now all you have to do is create a DNS record for your desired hostname and point that record to the second IP listed in the IP Addresses field for the balancer. In this case I need to point lbdemo.onapp.demo to 188.8.131.52.
After DNS propagation you can now test your service by visiting the designated hostname. As I keep refreshing the page, I can see that I’m being served by both nodes:
How simple is that? Load Balancing may seem a bit intimidating at first glance, but with OnApp it is easily accomplished with a few clicks.
In my next post, I’ll show how easy it is to set up autoscaling clusters in OnApp, too. An autoscaling cluster is a load balancer that monitors node usage, and that can automatically add or remove nodes from the cluster based on usage over a period of time.
In the meantime, if you have questions about load balancing (or autoscaling) with your OnApp cloud, our support team is available 24/7 to assist you in getting things up and running. You can submit a ticket through your account dashboard at https://admin.onapp.com or by sending an email directly to firstname.lastname@example.org.