Add a New Load Balancer
Operation description
Through this API, users can configure load balancing services according to their business needs, including but not limited to adaptive routing, weighted round-robin, rule matching, health checks, and other settings, to achieve effective traffic management and optimization.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- For mandatory resource types, indicate with a prefix of * .
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
esa:CreateLoadBalancer | create | *Site acs:esa:{#regionId}:{#accountId}:site/{#SiteId} |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
Name | string | Yes | The name of the load balancer, which must meet the domain name format validation and be a subdomain under the site. | lb.example.com |
Enabled | boolean | No | Whether the load balancer is enabled.
| true |
SiteId | long | Yes | Site ID, which can be obtained by calling the ListSites interface. | 123456789**** |
AdaptiveRouting | object | No | Configuration for failover across pools. | |
FailoverAcrossPools | boolean | No | Whether to failover across pools.
| true |
DefaultPools | array | Yes | List of default pools. | |
long | Yes | ID of the default pool, an integer. | 95223818027**** | |
FallbackPool | long | Yes | Fallback pool ID, where traffic will be directed when all other pools are unavailable. | 123 |
RandomSteering | object | No | Weighted round-robin configuration, used to control the traffic distribution weights among different pools. | |
DefaultWeight | integer | No | Default weight for round-robin, used for all pools that do not have a specific weight set. The value range is an integer between 0 and 100. | 50 |
PoolWeights | object | No | Weight configuration for each backend server pool, with the key being the pool ID and the value being the weight coefficient. The weight coefficient represents the proportion of relative traffic distribution. | |
integer | No | Weight for a single origin pool, a number between 0 and 100, where 0 means no traffic will be directed to that pool. | 50 | |
Rules | array<object> | No | Rule information. | { "ENAM": [ 12345678**** ], "WNAM": [ 23456789****, 23456789**** ] } |
object | No | Rule structure. | ||
RuleName | string | No | Rule name. This parameter does not need to be set when adding global configurations. | rule_1 |
Rule | string | No | Rule content, using conditional expressions to match user requests. This parameter does not need to be set when adding global configurations. There are two usage scenarios:
| (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 | Rule switch. This parameter does not need to be set when adding global configurations. Value range:
| on |
FixedResponse | object | No | Execute a specified response after matching the rule. | |
ContentType | string | No | Content-Type field in the HTTP Header. | application/octet-stream |
Location | string | No | Location field in the HTTP response. | http://www.example.com/index.html |
MessageBody | string | No | Response body value. | Hello World! |
StatusCode | integer | No | Response status code. | 200 |
Overrides | any | No | Modify the corresponding load balancing configuration after matching the rule. The fields in the configuration will override 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 execution order of the rule. It can be left blank, in which case the rules will be executed in the order they appear in the list. If specified, it should be an integer greater than 0, with higher values indicating a higher priority for execution. | 1 |
Terminates | boolean | No | Whether to terminate the execution of subsequent rules.
| true |
SessionAffinity | string | No | Session persistence, with possible values:
| ip |
SteeringPolicy | string | Yes | Load balancing strategy.
| order |
Description | string | No | Detailed description of the load balancer, for easier management and identification. | |
Ttl | integer | No | TTL value, the time-to-live for DNS records, with a default of 30 seconds. The value range is 10-600. | 300 |
Monitor | object | Yes | Monitor configuration, used for health checks. | |
Type | string | No | Monitor protocol type, such as HTTP, used for health checks. When set to
| HTTP |
Method | string | No | Monitor request method, such as | GET |
Port | integer | No | Origin server port. | 1921 |
Path | string | No | Monitor check path, such as | /health |
Interval | integer | No | Monitoring interval, such as | 60 |
Timeout | integer | No | Application health check timeout, in seconds, with a value range of 1-10. | 5 |
ExpectedCodes | string | No | Expected status codes, such as | 200 |
FollowRedirects | boolean | No | Whether to follow redirects.
| true |
ConsecutiveUp | integer | No | Number of consecutive successful probes required to consider the target healthy, such as | 3 |
ConsecutiveDown | integer | No | Number of consecutive failed probes required to consider the target unhealthy, such as | 5 |
Header | any | No | Header information included in the probe, which is the HTTP header. | { "host": [ "example1.com", "example2.com" ] } |
SubRegionPools | any | No | Address pools corresponding to secondary regions. When multiple secondary regions share a set of address pools, the keys can be concatenated with commas. | {"AL,MO": [92298024898****],"CN-SH,CN-SX,CN-SC":[92304347804****,92843536908****]} |
RegionPools | any | No | Address pools corresponding to primary regions. | { "ENAM": [ 12345678**** ], "WNAM": [ 23456789****, 23456789**** ] } |
Response parameters
Examples
Sample success responses
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. |
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. |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2025-02-13 | The Error code has changed. The request parameters of the API has changed | View Change Details |
2025-02-10 | The Error code has changed | View Change Details |