edit-icon download-icon

Server Load Balancer

Last Updated: Mar 20, 2018

Alibaba Cloud Server Load Balancer (SLB) is a traffic distribution control service that distributes the incoming traffic among multiple Elastic Compute Service (ECS) instances according to the configured forwarding rules. It expands the service capabilities of the application and increases the availability of the application. For more information, see Server Load Balancer documentation.

This tutorial uses the CreateLoadBalancer API of SLB as an example to demonstrate how to use Alibaba Cloud Python SDK to call SLB APIs.

Note: Running the code in this example will create an SLB instance and generate fees.

  1. from aliyunsdkcore.client import AcsClient
  2. from aliyunsdkcore.acs_exception.exceptions import ClientException
  3. from aliyunsdkcore.acs_exception.exceptions import ServerException
  4. from aliyunsdkslb.request.v20140515 import CreateLoadBalancerRequest
  5. # Create the AcsClient instance
  6. client = AcsClient(
  7. "<your-access-key-id>",
  8. "<your-access-key-secret>",
  9. "<your-region-id>"
  10. );
  11. # Create an SLB instance
  12. request = CreateLoadBalancerRequest.CreateLoadBalancerRequest()
  13. request.set_LoadBalancerName('MyLoadBalancer')
  14. request.set_AddressType('internet')
  15. request.set_InternetChargeType('paybytraffic')
  16. response = client.do_action_with_exception(request)
  17. print response
Thank you! We've received your feedback.