We recently announced the launch of our new service our new Multai Load Balancer service. Our new load balancer supports multi-cloud deployments and with 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!
- Log into the MLB console and browse to “Projects” from the menu bar and click “Create”. Add name and description as you can see below.
- Click on “</>” (API Keys) on the menu bar. Click on the “Generate” button to generate a new API key. Enter a descriptive name for this key then click “Generate”
- Click on “Deployments” on the left menu and then click on the “Create” button. Add a descriptive name for your deployment like “PACKET_EWR” (Cloud Provider _ Region) then click “Create”.
The API key will be displayed on the screen. Please copy this key and keep it somewhere safe. This key will not be available to you again from the console.
- Click on the name of the deployment you just created.
- Click on “Add New Host” and a new text box will appear with the install script for the MLB node runtime. Copy this script and place it into a text editor. Replace the <TOKEN> string with the token string that was generated in step 3. above. The finished script should look similar to what you see below.
- Open your Packet.net console and click on “Deploy” to launch a new server. Choose your project, select “servers” and click “Proceed”.
- Enter a descriptive hostname, select your type, os (Centos 7 is recommended), and location. We do recommend launching more than one server for the best availability.
- Click on “Manage” and then add the userdata script from step 5 above then click “Save & Continue”.
- Once the new MLB Runtime Nodes are launched they will appear under the deployment that you created in step 3 above. The nodes should appear as “Healthy”, the “Leader” node will be in charge of performing the health check of your target endpoints.
- Now that we have our MLB Runtime nodes up and running we can create a new Balancer. 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.
- 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 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.