CreateLoadBalancer
1. API Description
Domain name for API request: teo.tencentcloudapi.com.
This API is used to create a LoadBalancer. For details, see Quickly Create Load Balancers. The load balancing feature is in beta test. If you need to use it, contact us.
A maximum of 20 requests can be initiated per second for this API.
2. Input Parameters
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
Parameter Name | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Common Params. The value used for this API: CreateLoadBalancer. |
Version | Yes | String | Common Params. The value used for this API: 2022-09-01. |
Region | No | String | Common Params. This parameter is not required. |
ZoneId | Yes | String | Zone ID. |
Name | Yes | String | LoadBalancer name, which can contain 1 to 200 characters, including a-z, A-Z, 0-9, underscores (_), and hyphens (-). |
Type | Yes | String | LoadBalancer type. Valid values: |
OriginGroups.N | Yes | Array of OriginGroupInLoadBalancer | List of origin server groups and their corresponding disaster recovery scheduling priorities. For details, refer to Sample Scenario in Quickly Create Load Balancers. |
HealthChecker | No | HealthChecker | Health check policy. For details, refer to Health Check Policies. If left empty, health check is disabled by default. |
SteeringPolicy | No | String | Traffic scheduling policy among origin server groups. Valid values: |
FailoverPolicy | No | String | Request retry policy when access to an origin server fails. For details, refer to Introduction to Request Retry Strategy. Valid values: |
3. Output Parameters
Parameter Name | Type | Description |
---|---|---|
InstanceId | String | CLB instance ID. |
RequestId | String | The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. |
4. Example
Example1 Creating a LoadBalancer with the Health Check Policy Set to ICMP Ping
This example shows you how to create a LoadBalancer by selecting ICMP Ping for a health check policy and OtherRecordInOriginGroup for a request retry policy.
Input Example
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLoadBalancer
<Common request parameters>
{
"ZoneId": "zone-2ju9lrnpaxol",
"Name": "ICMP-LB",
"Type": "HTTP",
"OriginGroups": [
{
"Priority": "priority_1",
"OriginGroupId": "og-30l5kv5z2bse"
},
{
"Priority": "priority_2",
"OriginGroupId": "og-30l5kv5z2bse"
}
],
"HealthChecker": {
"Type": "ICMP Ping",
"Interval": 30,
"Timeout": 5,
"HealthThreshold": 3,
"CriticalThreshold": 2
},
"SteeringPolicy": "Pritory",
"FailoverPolicy": "OtherRecordInOriginGroup"
}
Output Example
{
"Response": {
"RequestId": "c2967195-cfd7-4bd0-ac05-d2eaccde6909",
"InstanceId": "lb-2osw7z07dnyu"
}
}
Example2 Creating a LoadBalancer with the Health Check Policy Set to HTTPS
This example shows you how to create a LoadBalancer by selecting HTTPS for a health check policy and OtherRecordInOriginGroup for a request retry policy.
Input Example
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLoadBalancer
<Common request parameters>
{
"ZoneId": "zone-2ju9lrnpaxol",
"Name": "HTTPS-LB",
"Type": "GENERAL",
"OriginGroups": [
{
"Priority": "priority_1",
"OriginGroupId": "og-30l5kv5z2bse"
},
{
"Priority": "priority_2",
"OriginGroupId": "og-30l5kv5z2bse"
},
{
"Priority": "priority_3",
"OriginGroupId": "og-30l5kv5z2bse"
}
],
"HealthChecker": {
"Type": "HTTPS",
"Path": "www.example.com/test",
"Port": 80,
"Interval": 30,
"Method": "HEAD",
"ExpectedCodes": [
"200",
"500",
"501",
"502",
"503",
"504",
"505",
"507",
"520",
"521",
"525",
"530",
"544",
"562",
"567",
"599"
],
"FollowRedirect": "true",
"Headers": [
{
"Key": "header1",
"Value": "header1"
},
{
"Key": "header2",
"Value": "header2"
},
{
"Key": "header3",
"Value": "header3"
}
],
"Timeout": 5,
"HealthThreshold": 3,
"CriticalThreshold": 2
},
"SteeringPolicy": "Pritory",
"FailoverPolicy": "OtherRecordInOriginGroup"
}
Output Example
{
"Response": {
"RequestId": "c2967195-cfd7-4bd0-ac05-d2eaccde6909",
"InstanceId": "lb-2osw7z17dnyu"
}
}
Example3 Creating a LoadBalancer with the Health Check Policy Set to HTTP
This example shows you how to create a LoadBalancer by selecting HTTP for a health check policy and OtherRecordInOriginGroup for a request retry policy.
Input Example
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLoadBalancer
<Common request parameters>
{
"ZoneId": "zone-2ju9lrnpaxol",
"Name": "HTTP-LB",
"Type": "GENERAL",
"OriginGroups": [
{
"Priority": "priority_1",
"OriginGroupId": "og-30l5kv5z2bse"
},
{
"Priority": "priority_2",
"OriginGroupId": "og-30l5kv5z2bse"
},
{
"Priority": "priority_3",
"OriginGroupId": "og-30l5kv5z2bse"
}
],
"HealthChecker": {
"Type": "HTTP",
"Path": "www.example.com/test",
"Port": 80,
"Interval": 30,
"Method": "HEAD",
"ExpectedCodes": [
"200",
"500",
"501",
"502",
"503",
"504",
"505",
"507",
"520",
"521",
"525",
"530",
"544",
"562",
"567",
"599"
],
"FollowRedirect": "true",
"Headers": [
{
"Key": "header1",
"Value": "header1"
},
{
"Key": "header2",
"Value": "header2"
},
{
"Key": "header3",
"Value": "header3"
}
],
"Timeout": 5,
"HealthThreshold": 3,
"CriticalThreshold": 2
},
"SteeringPolicy": "Pritory",
"FailoverPolicy": "OtherRecordInOriginGroup"
}
Output Example
{
"Response": {
"RequestId": "c2967195-cfd7-4bd0-ac05-d2eaccde6909",
"InstanceId": "lb-2osw7z07dnyu"
}
}
Example4 Creating a LoadBalancer with the Health Check Policy Set to TCP
This example shows you how to create a LoadBalancer by selecting TCP for a health check policy and OtherOriginGroup for a request retry policy.
Input Example
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLoadBalancer
<Common request parameters>
{
"ZoneId": "zone-2ju9lrnsaxol",
"Name": "TCP-LB",
"Type": "HTTP",
"OriginGroups": [
{
"Priority": "priority_1",
"OriginGroupId": "og-30l5kv5z2bse"
},
{
"Priority": "priority_2",
"OriginGroupId": "og-30l5kv5z2bse"
}
],
"HealthChecker": {
"Type": "TCP",
"Port": 80,
"Interval": 30,
"Timeout": 5,
"HealthThreshold": 3,
"CriticalThreshold": 2
},
"SteeringPolicy": "Pritory",
"FailoverPolicy": "OtherOriginGroup"
}
Output Example
{
"Response": {
"RequestId": "afe08af5-51f3-4f2e-911b-987ebb88a572",
"InstanceId": "lb-2osbdyhu19iy"
}
}
Example5 Creating a LoadBalancer with the Health Check Policy Set to UDP
This example shows you how to create a LoadBalancer by selecting UDP for a health check policy and OtherOriginGroup for a request retry policy.
Input Example
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLoadBalancer
<Common request parameters>
{
"ZoneId": "zone-2ju9lsnpaxol",
"Name": "UDP-LB",
"Type": "GENERAL",
"OriginGroups": [
{
"Priority": "priority_1",
"OriginGroupId": "og-30l5kv5z215e"
},
{
"Priority": "priority_2",
"OriginGroupId": "og-30l5kv5z2bse"
}
],
"HealthChecker": {
"Type": "UDP",
"Port": 80,
"SendContext": "requestcontent",
"RecvContext": "responsecontent",
"Interval": 30,
"Timeout": 5,
"HealthThreshold": 3,
"CriticalThreshold": 2
},
"SteeringPolicy": "Pritory",
"FailoverPolicy": "OtherOriginGroup"
}
Output Example
{
"Response": {
"RequestId": "57d0154c-f9ab-42b7-ad83-232106647ff3",
"InstanceId": "lb-2oswhs520uqe"
}
}
Example6 Creating a LoadBalancer with Probe Disabled
This example shows you how to create a LoadBalancer by selecting OtherOriginGroup for a request retry policy without enabling any health check policy. It is suitable for scenarios with only primary and replica origin servers configured.
Input Example
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLoadBalancer
<Common request parameters>
{
"ZoneId": "zone-2ju9lrnpaxol",
"Name": "NoCheck-LB",
"Type": "HTTP",
"OriginGroups": [
{
"Priority": "priority_1",
"OriginGroupId": "og-30l5kv5z2bse"
},
{
"Priority": "priority_2",
"OriginGroupId": "og-30l5kv5z2ase"
}
],
"HealthChecker": {
"Type": "NoCheck"
},
"SteeringPolicy": "Pritory",
"FailoverPolicy": "OtherOriginGroup"
}
Output Example
{
"Response": {
"RequestId": "2c619f7f-27e9-43c5-b42c-68dcca803d35",
"InstanceId": "lb-2osw2ssziowm"
}
}
5. Developer Resources
SDK
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
- Tencent Cloud SDK 3.0 for Python
- Tencent Cloud SDK 3.0 for Java
- Tencent Cloud SDK 3.0 for PHP
- Tencent Cloud SDK 3.0 for Go
- Tencent Cloud SDK 3.0 for Node.js
- Tencent Cloud SDK 3.0 for .NET
- Tencent Cloud SDK 3.0 for C++
Command Line Interface
6. Error Code
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
Error Code | Description |
---|---|
InvalidParameter.LoadBalancerNameRepeated | The LoadBalancer names under the same site should be unique. |
InvalidParameter.OriginGroupTypeCanNotMatchLBType | The type of the origin server group does not match the LoadBalancer type. |
InvalidParameter.SomeOriginGroupNotExist | Some bound origin server groups do not exist. |
LimitExceeded.LoadBalancingCountLimitExceeded | The number of LoadBalancers exceeds the limit. |
- 1. API Description
- 2. Input Parameters
- 3. Output Parameters
- 4. Example
- Example1 Creating a LoadBalancer with the Health Check Policy Set to ICMP Ping
- Example2 Creating a LoadBalancer with the Health Check Policy Set to HTTPS
- Example3 Creating a LoadBalancer with the Health Check Policy Set to HTTP
- Example4 Creating a LoadBalancer with the Health Check Policy Set to TCP
- Example5 Creating a LoadBalancer with the Health Check Policy Set to UDP
- Example6 Creating a LoadBalancer with Probe Disabled
- 5. Developer Resources
- SDK
- Command Line Interface
- 6. Error Code