January 26, 2016

Getting started with the SLCLI and Load Balancers Load Balancing is a way to distribute processing and communications evenly across multiple servers within a data center

Load Balancing is a way to distribute processing and communications evenly across multiple servers within a data center so that a single device does not carry an entire load. SoftLayer Load Balancing enables customers to employ a variety of balancing methods to distribute traffic, including persistent and non-persistent options, that can be changed, activated and deactivated at any time. Today we are going to look at how to use the Python slcli client to manage your SoftLayer Local Load balancers.

Load Balancer details

To obtain information about our load balancer we will use the detail command. This will provide us with a good overview of the basic configuration of our load balancer.

Adding new service groups

A Service Group is used to specify the type of traffic we want to distribute between our various servers. The current options are HTTP, DNS, FTP, HTTPS, TCP, and UDP. A service group will also determine the Balancing Methods or routing-methods we will use to balance our traffic. The routing-type and routing method take integer arguments which can be obtained using slcli loadbal routing-types and slcli loadbal routing-methods respectively.

In the following example we are setting up a 50⁄50 allocation group to balance both HTTP (routing type 2 using Round Robin) and FTP (routing type 3 using Consistent Hash IP).

Adding services to an existing group

In order to add a service to an existing group we need 2 pieces of information: the Service Group ID and the ID of the health check we want to set up for the service. We can get the health check ID with the command slcli loadbal health-checks

$ slcli loadbal health-checks
1 TCP
2 HTTP
3 DNS
4 Ping
5 HTTP-CUSTOM
21 Default
To set up an new service to balance port 80 on the server 172.16.0.1 we set the healthcheck-type to 2 and pass the --enabled flag.

When we check the details of the Load Balancer again we can see that the Enabled flag is now set to 0 (Disabled).
$ slcli –format=raw loadbal detail local:124185|grep ‘123456:428745’
Services 124185:436345 172.0.6.1 80 2:HTTP 10 0

Service delete

$ slcli loadbal service-delete 124185:428745
This action will cancel a service from your load balancer. Continue? [y/N]: y
Load balancer service 428745 is being cancelled!

Service group delete

$ slcli loadbal group-delete 124185:222089
This action will cancel a service group. Continue? [y/N]: y
Service group 124185:222089 is being deleted!