In this tutorial, we will show you how to deploy and load balance your applications on the Packet.net bare metal cloud service. We’ll first create a new MLB deployment, install the runtime on the MLB nodes, then create a new load balancer in the MLB console and load balance our test application. Let’s get started!
- On the left menu click on “Balancers” then click “Create”.
- Enter a descriptive name for your Balancer.
- Set the “Draining Timeout” section as you see fit or leave it at the default as you can see below. Idle duration is the number of seconds to elapse before a connection is closed by the MLB.
- Enter the Listener ports that will be used for your application. In my case, I have a simple Apache test site on port 80. You can have multiple virtual hosts with Apache on different ports per Apache server so enter all in use here. Press the “+ Add Listener” button to add them to the list.
- Add a target set: In the runtime, choose your data-center
- You can add advanced routing rules for your application servers. In my case, I have just one site running on port 80. You can configure multiple sites here (shown below) or configure Header based routing by entering a Header Key and Header Value
- A Target Set is a logical group of targets that share the same routing rule. In our case, we are creating a set of HTTP endpoints on port 80 to the root of the server “/”. Select the deployment that you created in step 3 above.
- Next, add the target name, address, port and weight as you can see below. You can add additional targets by clicking the “+ Add Target” button.
You can set the “Weight” for the target here. For example, if you added a new target with a weight of 2 it would have double the connections than a Target with a weight of 1. You can use this setting if you have servers with different performance specs like additional CPU cores or Memory.
- Now we can configure the “Health Check” for our MLB. In my case, I am using the default port 80 and the same path as the application “index.html”. You can change the default health check intervals and timeout settings here as well. According to the settings below a health, check will occur every 10 seconds and will wait up to 5 seconds for a timeout. Targets will be marked as “Healthy” after 2 consecutive passing health checks and “Unhealthy” after failing 3 consecutive health checks.
- Lastly, we can click the “Create Load Balancer” button at the bottom of the page to create the Load Balancer.
- You will now see your new Balancer from the Balancer list. Notice that a new DNS record was created specifically for your Balancer. Click on the name of your Balancer.
- You will see the Target Sets that you created back in step 14. Click on the name of your Target Set.
- You will see the status of the targets that you created in step 15 above. If the targets are not reporting as “Healthy” make sure that you have access rules allowing connectivity from your MLB Runtime Nodes to your Target servers. Test by connecting the lead Runtime server and connect to the Apache server using curl. If you are not receiving an HTTP 200 response then you may need to change security rules or the configuration of your web server. If you need to perform maintenance on your servers you can temporarily remove them from the balancer by changing the “Readiness” from “Ready” to “Maintenance”. Switch the target back to healthy when finished.
- Now that we have verified the Targets are healthy go back to the “Balancers” page. Open the DNS name that was created as shown in step 17 above. You should now be able to access your newly MLB balanced application from the DNS record. Once you have verified everything is working you can create a cname in your own DNS management.