Creates a load balancer instance that supports custom routing policies, session persistence, monitoring configurations, and other advanced features.
Operation description
Creates a load balancing service based on your business requirements. You can configure settings such as adaptive routing, weighted polling, rule matching, and health checks to effectively manage and optimize traffic.
Only Enterprise plans support the load balancing service. To use this feature, contact Alibaba Cloud sales to apply for an Enterprise plan.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
esa:CreateLoadBalancer |
create |
*Site
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Name |
string |
Yes |
The name of the load balancer. The name must be in a valid domain name format and must be a subdomain of the site. |
lb.example.com |
| Enabled |
boolean |
No |
Specifies whether the load balancer is enabled. Valid values:
Valid values:
|
true |
| SiteId |
integer |
Yes |
The site ID. You can call the ListSites operation to obtain the site ID. |
123456789**** |
| AdaptiveRouting |
object |
No |
The cross-origin address pool back-to-origin configuration. |
true |
| FailoverAcrossPools |
boolean |
No |
Specifies whether to enable cross-origin address pool failover. Valid values:
|
true |
| OriginLevelRetry |
boolean |
No |
Specifies whether to retry the next IP address when back-to-origin fails and the origin server is a domain name that resolves to multiple IP addresses. |
false |
| DefaultPools |
array |
Yes |
The list of default address pool IDs. |
123 |
|
integer |
No |
The default address pool ID. The value is an integer. |
95223818027**** |
|
| FallbackPool |
integer |
Yes |
The fallback address pool ID. Traffic is directed to this pool when all other pools are unavailable. |
123 |
| RandomSteering |
object |
No |
The weighted round-robin configuration that controls the traffic distribution weight across different address pools. |
123 |
| DefaultWeight |
integer |
No |
The default round-robin weight applied to all address pools that do not have an individually specified weight. Valid values: integers from 0 to 100. |
50 |
| PoolWeights |
object |
No |
The weight configuration for each backend server pool. The key is the pool ID and the value is the weight coefficient. The weight coefficient represents the relative proportion of traffic distribution. |
|
|
integer |
No |
The weight of a single origin address pool. Valid values: 0 to 100. A value of 0 indicates that no traffic is routed to this origin address pool. |
50 |
|
| Rules |
array<object> |
No |
The rule information. |
{ "ENAM": [ 12345678**** ], "WNAM": [ 23456789****, 23456789**** ] } |
|
array<object> |
No |
The rule struct. |
||
| RuleName |
string |
No |
The rule name. This parameter is not required when you add a global configuration. |
rule_1 |
| Rule |
string |
No |
The rule content that uses conditional expressions to match user requests. This parameter is not required when you add a global configuration. Two scenarios are supported:
|
(http.request.method eq "GET" and http.request.version eq "HTTP/1.0") or (ip.geoip.country eq "CN") or (http.host eq "www.example.com") |
| RuleEnable |
string |
No |
The rule switch. This parameter is not required when you add a global configuration. Valid values:
|
on |
| FixedResponse |
object |
No |
The fixed response content returned after a rule is matched. |
{"content_type": "application/json", "location": "www.example.com", "message_body": "Testing Hello", "status_code": 0} |
| ContentType |
string |
No |
The Content-Type field in the HTTP header. |
application/octet-stream |
| Location |
string |
No |
The location field in the HTTP response. |
http://www.example.com/index.html |
| MessageBody |
string |
No |
The response body value. |
Hello World! |
| StatusCode |
integer |
No |
The response status code. |
200 |
| Overrides |
any |
No |
The load balancing configuration that overwrites the corresponding fields in the load balancer configuration when a rule is matched. The specified fields overwrite the corresponding fields in the load balancer configuration. |
{ "adaptive_routing": { "failover_across_pools": true }, "sub_region_pools": { "AL,AT": [ 92298024898****, 92304347804**** ], "BG,BY": [ 92298024898**** ] }, "default_pools": [ 92298024898****, 92304347804**** ], "fallback_pool": 92298024898****, "location_strategy": { "mode": "resolver_ip", "prefer_ecs": "always" }, "random_steering": { "default_weight": 0.3, "pool_weights": { "92298024898****": 0.7, "92304347804****": 0.8 } }, "region_pools": { "CN,SEAS": [ 92298024898****, 92304347804**** ], "SAF,SAS": [ 92304347804**** ] }, "session_affinity": "ip", "steering_policy": "geo", "ttl": 30 } |
| Sequence |
integer |
No |
The rule execution order. This parameter is optional. If not specified, rules are executed in list order. If specified, the value must be a positive integer. A larger value indicates a higher priority. |
1 |
| Terminates |
boolean |
No |
Specifies whether to stop executing subsequent rules. Valid values:
|
true |
| SessionAffinity |
string |
No |
The session persistence mode. Valid values:
|
ip |
| SteeringPolicy |
string |
Yes |
The load balancing policy. Valid values:
|
order |
| Description |
string |
No |
The description of the load balancer for management and identification purposes. |
Load Balancer Description |
| Ttl |
integer |
No |
The TTL value, which specifies the time-to-live of the DNS record. Default value: 30 seconds. Valid values: 10 to 600. |
300 |
| Monitor |
object |
Yes |
The monitor configuration for health checks. |
order |
| Type |
string |
No |
The monitor protocol type used for health checks. A value of off indicates that health checks are disabled. Valid values:
|
HTTP |
| Method |
string |
No |
The monitor request method, such as |
GET |
| Port |
integer |
No |
The origin server port. |
1921 |
| Path |
string |
No |
The monitor check path, such as |
/health |
| Interval |
integer |
No |
The monitoring interval in seconds, such as |
60 |
| Timeout |
integer |
No |
The health check timeout period. Unit: seconds. Valid values: 1 to 10. |
5 |
| ExpectedCodes |
string |
No |
The expected status codes, such as |
200 |
| FollowRedirects |
boolean |
No |
Specifies whether to follow redirects. Valid values:
|
true |
| ConsecutiveUp |
integer |
No |
The number of consecutive successful probes required to consider the check successful, such as |
3 |
| ConsecutiveDown |
integer |
No |
The number of consecutive failed probes required to consider the check failed, such as |
5 |
| Header |
any |
No |
The header information included in the probe request. This is the HTTP header. |
{ "host": [ "example1.com", "example2.com" ] } |
| MonitoringRegion |
string |
No |
The region where the probe nodes are located. Default value: Global. Valid values:
Valid values:
|
Global |
| SubRegionPools |
any |
No |
The address pools mapped to secondary regions. If multiple secondary regions share the same set of address pools, you can concatenate the secondary region names with commas as the key. |
{"AL,MO": [92298024898****],"CN-SH,CN-SX,CN-SC":[92304347804****,92843536908****]} |
| RegionPools |
any |
No |
The address pools mapped to primary regions. |
{ "ENAM": [ 12345678**** ], "WNAM": [ 23456789****, 23456789**** ] } |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Schema of Response |
||
| RequestId |
string |
The request ID. |
EEEBE525-F576-1196-8DAF-2D70CA3F4D2F |
| Id |
integer |
The load balancer ID. |
99867648760**** |
Examples
Success response
JSON format
{
"RequestId": "EEEBE525-F576-1196-8DAF-2D70CA3F4D2F\n",
"Id": 0
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameter | The specified parameter is invalid. | The specified parameter is invalid. |
| 400 | LoadBalancerQuotaCheckFailed | Load balancer enable quota check failed. | Your current plan cannot use the load balancer related functions. If you need to use it, upgrade the plan. |
| 400 | LoadBalancerNumberExceedQuotaLimit | The number of load balancers you have added has reached the limit of the plan quota. Please delete the unused load balancers or upgrade the plan and try again. | The number of load balancers you have added has reached the limit of the plan quota. Please delete the unused load balancers or upgrade the plan and try again. |
| 400 | LoadBalancerRuleQuotaCheckFailed | Your current plan does not support configuring load balancer custom rules, or the load balancer rules you have added exceed the plan quota limit. Please upgrade the plan or delete the rules that are no longer in use and try again. | Your current plan does not support configuring load balancer custom rules, or the load balancer rules you have added exceed the plan quota limit. Please upgrade the plan or delete the rules that are no longer in use and try again. |
| 400 | LoadBalancerPolicyCheckFailed | Your current plan does not support the load balancer scheduling policy. Upgrade the plan and try again. | Your current plan does not support the load balancer scheduling policy. Upgrade the plan and try again. |
| 400 | LoadBalancerHealthDetectionQuotaCheckFailed | Your current plan does not allow you to configure the load balancer's health detection. Upgrade the plan and try again. | Your current plan does not allow you to configure the load balancer's health detection. Upgrade the plan and try again. |
| 400 | LoadBalancerHealthDetectionIntervalCheckFailed | The configured load balancer health detection interval exceeds the quota range allowed by the plan. Please revise the interval within the range or upgrade the plan and try again. | The configured load balancer health detection interval exceeds the quota range allowed by the plan. Please revise the interval within the range or upgrade the plan and try again. |
| 400 | InternalException | Failed to call the service. Try again later or contact technical support. | Failed to call the service. Try again later or contact technical support. |
| 400 | Instance.NotOnline | Your plan is unavailable due to an overdue payment. Complete the payment first. | Your plan is unavailable due to an overdue payment. Complete the payment first. |
| 400 | MonitorExpectedBodyInvalid | Invalid response body. Specify a response body that does not exceed 102,400 characters in length in your custom rule. | Invalid response body. Specify a response body that does not exceed 102,400 characters in length in your custom rule. |
| 400 | MonitorExpectedCodesInvalid | Invalid expected status code for the probe.Make sure that you specify no more than 10 status codes in the probe settings, and each status code must be 3 to 4 characters in length.Examples: 200, 301, 3xx, 8000, and 88xx. | Invalid expected status code for the probe.Make sure that you specify no more than 10 status codes in the probe settings, and each status code must be 3 to 4 characters in length.Examples: 200, 301, 3xx, 8000, and 88xx. |
| 400 | MonitorHeaderInvalid | Invalid request header for the probe. You can add up to 10 request headers, each with 1 to 9 values. The combined length of all headers and values cannot exceed 6,000 characters. You cannot configure the User-Agent header. | The incoming monitor is carrying an illegal request header. Make sure that the number of request headers does not exceed 10, that each request header has a value length between 1 and 10, and that you must not use the User-Agent request header (which is reserved for internal specific scenarios). In addition, the total length of all request headers and their values must not exceed 6000 characters. Please check and correct the request header configuration and try again. |
| 400 | MonitorMethodNotSupport | Invalid HTTP method for the probe request. Valid values are GET and HEAD. | Invalid HTTP method for the probe request. Valid values are GET and HEAD. |
| 400 | MonitorPathNotSupport | Invalid probe URL path.If you set the probe protocol to HTTP or HTTPS, make sure you specify a probe URL path that does not exceed 1,024 characters in length. | Invalid probe URL path.If you set the probe protocol to HTTP or HTTPS, make sure you specify a probe URL path that does not exceed 1,024 characters in length. |
| 400 | MonitorPortNotSupport | Invalid probe port. Specify a valid port from 1 to 65535 for the probe request. Then, try again. | The incoming monitor listening port is not supported. The port value range is [1-65535]. Please ensure that the port is within the value range and try again. |
| 400 | MonitorRetriesInvalid | Invalid number of probe retries. Specify an integer from 0 to 5. Then, try again. | Invalid number of probe retries. Specify an integer from 0 to 5. Then try again. |
| 400 | MonitorTimeoutInvalid | Invalid timeout for the probe. Valid values are 1 to 10. | Invalid timeout for the probe. Valid values are 1 to 10. |
| 400 | MonitorTypeNotSupport | Invalid protocol. Valid values are off, HTTP, HTTPS, TCP, UDP, ICMP Ping, and SMTP. | Invalid protocol. Valid values are off, HTTP, HTTPS, TCP, UDP, ICMP Ping, and SMTP. |
| 400 | OriginPoolNotExist | The specified origin pool does not exist or does not belong to your account or website. Check and try again. | The specified origin pool does not exist or does not belong to your account or website. Check and try again. |
| 400 | LoadBalancerNameConflict | The load balancer name or the hostname for the origin pool already exists. Try again with a unique name. | The load balancer name or the hostname for the origin pool already exists. Try again with a unique name. |
| 400 | LockFailed | The system is handling requests you previously submitted. Try again later. | The system is handling requests you previously submitted. Try again later. |
| 400 | SourceCircleExist | The host record of the resource to be operated on is already the source station of another resource, or the source station of the current resource has been added as a host record. To avoid loopback, modify the host record or source station and retry. | The host record of the resource to be operated on is already the source station of another resource, or the source station of the current resource has been added as a host record. To avoid loopback, modify the host record or source station and retry. |
| 400 | LoadBalancer.NameInvalid | The name of the Server Load Balancer instance is a valid domain name or belongs to the site. Check that it is correct and try again. | The name of the Server Load Balancer instance is a valid domain name or belongs to the site. Check that it is correct and try again. |
| 400 | CompileRuleError | Rule compilation failed, please check the rule information passed in to ensure that the rule is written according to the syntax described in the document. | Rule compilation failed. Check the incoming rule configuration. For details, see the rule configuration format described in the interface document. |
| 400 | InstanceNotExist | The instance does not exist. Check whether the specified instance ID is correct or whether the instance belongs to your account. | The instance does not exist. Check whether the specified instance ID is correct or whether the instance belongs to your account. |
| 403 | QuotaExceeded | The quota is exceeded. | The quota is exceeded. |
| 404 | SiteNotFound | The website does not exist or does not belong to you. | The website does not exist or does not belong to you. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.