In Web+, if multiple ECS instances exist in an environment, you can use Server Load Balancer (SLB) to distribute workloads across these ECS instances. With traffic distribution, SLB allows you to enhance service capabilities, remove single points of failure, and improve the availability of applications.

Background information

When you select a surrogate purchase for an SLB instance, Web+ helps you purchase the new SLB instance and configure listening ports and forwarding rules. Therefore, you can focus on your core business rather than using your time to learn about the underlying configurations of SLB. The default instance type for a surrogate SLB instance is slb.s1.small. The billing method is pay-as-you-go.

If you have created one or more SLB instances before using Web+, you can select the Import mode. This mode allows you to import these SLB instances and configure listening ports and server groups. After the configuration is complete, Web+ synchronizes ECS instances that reside in an environment to the specified server group.

In Web+, you can create an Internet-facing SLB instance to allow access to an application from the Internet. You can also create an internal SLB instance. This type of SLB instances only allows access to an application from applications on clients that reside in the same VPC as a client that hosts the application. The procedure to create an Internet-facing SLB instance or an internal SLB instance is similar. This topic takes the procedure to create an Internet-facing SLB instance as an example.

Surrogate SLB instances

  1. On the Environment Details page, select Configurations, and view the Internet-facing SLB setting.
  2. Turn on the Enable Internet-facing SLB switch.
  3. Select Surrogate Purchase as the Instance Source.
  4. Enter a port number in the SLB Listening Port setting.

    The listening port of the SLB instance. You can use the port to access applications over the Internet. If an SLB instance is purchased by Web+ on your behalf, Web+ will help you create and maintain a listening port.

  5. Configure the SLB Protocol.

    The protocol type of request traffic that Server Load Balancer supports routing to different ports on instances. Available protocols include TCP and HTTP. If you specify HTTP as the SLB protocol, you can configure a forwarding policy. Only HTTP request traffic that conforms to the specified forwarding policy will be routed to instances that reside in the current environment.

  6. Configure the SLB Forwarding Policy. The setting is only available when you select HTTP for the SLB Protocol setting.
    A valid forwarding policy includes at least a fully qualified domain name (FQDN) or a directory. Examples of valid forwarding policies are listed as follows:
    • www.taobao.com/test
    • www.taobao.com
    • /test

Self-imported SLB instances

  1. On the Environment Details page, select Configurations, and view the Internet SLB setting.
  2. Turn on the Enable Internet SLB switch.
  3. Select Import as the Instance Source.
  4. On the list of SLB instances, select an existing SLB instance.
  5. Enter a port number in the SLB Listening Port.

    The listening port of the SLB instance. You can use the port to access applications over the Internet. If you import existing SLB instances, the listening port is used as part of an Internet access address. You must ensure that the port is identical to the port that is linked to the specified VServer group.

  6. Configure the SLB Server Group Type.
    • Default Server Group: includes one or more ECS instances that accept requests from clients. If no VServer group is available, all requests are forwarded to ECS instances that reside in the default server group.
    • VServer Group: You can select an existing VServer group or click Create VServer Group to create a new VServer group. Then, you can click the ID of a VServer group to go to the SLB console to configure listing ports and forwarding policies.

      When you want to forward requests to different backend servers or forward requests based on domain names or URLs, you can specify a VServer group.

      When you scale an environment, Web+ will synchronize ECS instances to the specified VServer group.

Disable SLB

After you disable SLB, Web+ uses the following policies to release SLB instances:
  • Surrogate SLB instances: After you disable SLB, Web+ removes all ECS instances, forwarding policies, and listeners that reside in the specified VServer group of an environment. The SLB instance will also be released. If the SLB instance is being used by other applications, Web+ removes all ECS instances, forwarding policies, and listeners but retains the SLB instance.
  • Self-imported SLB instances: Web+ removes all ECS instances that reside in the specified VServer group of an environment but retains the SLB instance.

Use the CLI tool to configure SLB

The CLI tool uses the Wpfile file to configure SLB. You can use the wpctl dump command to retrieve the Wpfile file of a environment. You can use the CLI tool to add, modify, and delete SLB settings. Then, you can use the apply command to enable the configuration.

In the Wpfile file, Internet-facing SLB settings are sorted into the resources.slb.internet category and internal SLB settings are sorted into the resources.slb.intranet category. An identical set of settings applies to both Internet-facing SLB and internal SLB. The following table describes the SLB settings.

Setting Valid values Default value
enable true and false false Specifies whether to enable SLB.
imported true and false false Specifies whether to import an existing SLB instance.
importedGroupType defaultGroup

virtualGroup

virtualGroup
The server group type for the imported SLB instance. Valid values: defaultGroup specifies the default server group and virtualGroup specifies a VServer group.
vServerGroupId String The ID of the VServer group. If you import an SLB instance and the SLB Server Group Type is set to VServer Group, you must specify a VServer group ID.
slbId A valid SLB instance ID. None When you specify an SLB instance ID, Web+ configures the SLB instance based on your settings. Then, the SLB instance forwards specific traffic to ECS instances that reside in the current environment.
internetChargeType
  • paybytraffic
  • paybybandwidth
paybytraffic The billing item. Valid values: paybytraffic specifies that you are billed by traffic volume and paybybandwidth specifies that you are billed by bandwidth.
loadBalancerSpec
  • slb.s1.small
  • slb.s2.small
  • slb.s2.medium
  • slb.s3.small
  • slb.s3.medium
  • slb.s3.large
slb.s1.small The SLB instance type.
bandwidth Integer -1 The peak bandwidth parameter. When you set the billing method to paybybandwidth, the peak bandwidth parameter is available.
listenerPort Integer 80 The listening port.
protocol
  • HTTP
  • TCP
HTTP The listening protocol.
forwardingRule A valid forwarding policy includes at least an FQDN or directory. Examples of valid forwarding policies are listed as follows: www.taobao.com/test, www.taobao.com, and /test. None The forwarding policy parameter. When you set the listening protocol to HTTP, the forwarding policy parameter is available.