Creates a server group in a specified region.
Operation description
The CreateServerGroup API operation is asynchronous. After you call this operation, the system returns a request ID, but the server group is not yet created and the creation task is still running in the background. You can call the ListServerGroups operation to query the creation status of the server group:
If the server group is in the Creating state, the server group is being created.
If the server group is in the Available state, the server group is created.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
alb:CreateServerGroup |
create |
*ServerGroup
|
|
None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| ServerGroupName |
string |
Yes |
The name of the server group. The name must be 2 to 128 characters in length, and must start with a letter, Chinese character, or digit. It can contain digits, periods (.), underscores (_), hyphens (-), and spaces. |
test |
| ServerGroupType |
string |
No |
The type of the server group. Valid values:
|
Instance |
| VpcId |
string |
No |
The VPC-connected instance ID. Only servers in this VPC can be added to the server group. Note
This parameter takes effect only when ServerGroupType is set to Instance or Ip. |
vpc-bp15zdkdt37pq72zv**** |
| Scheduler |
string |
No |
The scheduling algorithm. Valid values:
Note
This parameter takes effect only when ServerGroupType is set to Instance or Ip. |
Wrr |
| Protocol |
string |
No |
The backend protocol. Valid values:
Note
You do not need to configure the backend protocol when ServerGroupType is set to Fc. |
HTTP |
| ResourceGroupId |
string |
No |
The ID of the resource group. |
rg-atstuj3rsop**** |
| HealthCheckConfig |
object |
Yes |
The health check configuration. |
rg-123 |
| HealthCheckConnectPort |
integer |
No |
The port of the backend server used for health checks. Valid values: 0 to 65535. Default value: 0, which indicates that the port of the backend server is used for health checks. |
80 |
| HealthCheckEnabled |
boolean |
Yes |
Specifies whether to enable health checks. Valid values:
Note
By default, health checks are enabled when ServerGroupType is set to Instance or Ip, and disabled when ServerGroupType is set to Fc. |
true |
| HealthCheckHost |
string |
No |
The domain name used for health checks. Valid values:
Note
This parameter takes effect only when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC. |
www.example.com |
| HealthCheckCodes |
array |
No |
The list of status codes that indicate a successful health check. |
|
|
string |
No |
The status codes that indicate a successful health check.
Note
This parameter takes effect only when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC. |
http_2xx |
|
| HealthCheckHttpVersion |
string |
No |
The HTTP version used for health checks. Valid values: HTTP1.0 and HTTP1.1 (default). Note
This parameter takes effect only when HealthCheckProtocol is set to HTTP or HTTPS. |
HTTP1.1 |
| HealthCheckInterval |
integer |
No |
The interval between two consecutive health checks. Unit: seconds. Valid values: 1 to 50. Default value: 2. |
2 |
| HealthCheckMethod |
string |
No |
The HTTP method used for health checks. Valid values:
Note
This parameter takes effect only when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC. |
HEAD |
| HealthCheckPath |
string |
No |
The path used for health checks. The path must be 1 to 80 characters in length, and can contain only letters, digits, and the following special characters: Note
This parameter takes effect only when HealthCheckProtocol is set to HTTP or HTTPS. |
/test/index.html |
| HealthCheckProtocol |
string |
No |
The protocol used for health checks. Valid values:
|
HTTP |
| HealthCheckTimeout |
integer |
No |
The timeout period for a health check response. If the backend server does not respond within the specified timeout period, the health check fails. Unit: seconds. Valid values: 1 to 300. Default value: 5. |
5 |
| HealthyThreshold |
integer |
No |
The number of consecutive successful health checks required to change the health check status of a backend server from Failed to Successful. Valid values: 2 to 10. Default value: 3. |
3 |
| UnhealthyThreshold |
integer |
No |
The number of consecutive failed health checks required to change the health check status of a backend server from Successful to Failed. Valid values: 2 to 10. Default value: 3. |
3 |
| StickySessionConfig |
object |
No |
The session persistence configuration. Note
This parameter takes effect only when ServerGroupType is set to Instance or Ip. |
|
| Cookie |
string |
No |
The cookie configured on the server. The cookie must be 1 to 200 characters in length, and can contain only ASCII letters and digits. It cannot contain commas (,), semicolons (;), or spaces, and cannot start with a dollar sign ($). Note
This parameter takes effect only when StickySessionEnabled is set to true and StickySessionType is set to server. |
B490B6EBF6F3CD402E515D22BCDA**** |
| CookieTimeout |
integer |
No |
The timeout period of the cookie. Unit: seconds. Valid values: 1 to 86400. Default value: 1000. Note
This parameter takes effect only when StickySessionEnabled is set to true and StickySessionType is set to Insert. |
1000 |
| StickySessionEnabled |
boolean |
No |
Specifies whether to enable session persistence. Valid values:
Note
This parameter takes effect only when ServerGroupType is set to Instance or Ip. |
false |
| StickySessionType |
string |
No |
The method used to handle cookies. Valid values:
Note
This parameter takes effect only when StickySessionEnabled is set to true. |
Insert |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The client token can contain only ASCII characters. Note
If you do not specify this parameter, the system automatically uses the RequestId of the API request as the ClientToken. The RequestId of each API request may be different. |
5A2CAF0E-5718-45B5-9D4D-70B****** |
| DryRun |
boolean |
No |
Specifies whether to only precheck the request. Valid values:
|
false |
| Ipv6Enabled |
boolean |
No |
Specifies whether the IP protocol version used by load balancing to forward traffic to the backend server group supports IPv6. Valid values:
|
true |
| UpstreamKeepaliveEnabled |
boolean |
No |
Specifies whether to enable backend keep-alive. Valid values:
|
false |
| ServiceName |
string |
No |
The name of the |
test |
| UchConfig |
object |
No |
The URL consistent hashing parameter settings. |
|
| Type |
string |
Yes |
The parameter type. Set the value to QueryString. |
QueryString |
| Value |
string |
Yes |
The consistent hashing parameter value. |
abc |
| ConnectionDrainConfig |
object |
No |
The graceful connection break configuration. After graceful connection break is enabled, load balancing allows existing connections to be transmitted normally within a specified period of time after a backend server is removed or a health check failed. Note
|
|
| ConnectionDrainEnabled |
boolean |
No |
Specifies whether to enable connection draining. Valid values:
|
false |
| ConnectionDrainTimeout |
integer |
No |
The connection draining timeout period. Valid values: 0 to 900. Default value: 300. |
300 |
| SlowStartConfig |
object |
No |
The slow start configuration. After slow start is enabled, newly added backend servers in the server group are warmed up within the specified time period, and the number of requests forwarded to the servers increases linearly. Note
|
|
| SlowStartEnabled |
boolean |
No |
Specifies whether to enable slow start. Valid values:
|
false |
| SlowStartDuration |
integer |
No |
The slow start duration. Valid values: 30 to 900. Default value: 30. |
30 |
| Tag |
array<object> |
No |
The tags. |
|
|
object |
No |
The tag structure. |
||
| Key |
string |
No |
The tag key. The key can be up to 128 characters in length, and cannot start with |
env |
| Value |
string |
No |
The tag value. The value can be up to 128 characters in length, and cannot start with |
product |
| CrossZoneEnabled |
boolean |
No |
Specifies whether to enable cross-zone load balancing for the server group. Valid values:
Note
|
true |
| IpVersionAffinityMode |
string |
No |
The IP version affinity mode. Valid values:
This parameter takes effect only when Ipv6Enabled is set to true. |
Affinity |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response data structure. |
||
| JobId |
string |
The ID of the asynchronous task. |
72dcd26b-f12d-4c27-b3af-18f6aed5**** |
| RequestId |
string |
The ID of the request. |
365F4154-92F6-4AE4-92F8-7FF****** |
| ServerGroupId |
string |
The ID of the server group. |
sgp-8ilqs4axp6****** |
Examples
Success response
JSON format
{
"JobId": "72dcd26b-f12d-4c27-b3af-18f6aed5****",
"RequestId": "365F4154-92F6-4AE4-92F8-7FF******",
"ServerGroupId": "sgp-8ilqs4axp6******"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | QuotaExceeded.ServerGroupsNum | The quota of %s is exceeded, usage %s/%s. | The quota of %s is exceeded, usage %s/%s. |
| 400 | Mismatch.LoadBalancerEditionAndSlowStartEnable | The %s and %s are mismatched. | The %s and %s are mismatched. |
| 400 | Mismatch.ServerGroupSchedulerAndSlowStartEnable | The %s and %s are mismatched. | The %s and %s are mismatched. |
| 400 | QuotaExceeded.SlowStartDuration | The quota of %s is exceeded, usage %s/%s. | The quota of %s is exceeded, usage %s/%s. |
| 400 | UnsupportedFeature.SlowStart | The feature of %s is not supported. | The feature %s is not supported. |
| 400 | Mismatch.LoadBalancerEditionAndConnectionDrain | The %s and %s are mismatched. | The %s and %s are mismatched. |
| 400 | QuotaExceeded.ConnectionDrainTimeout | The quota of %s is exceeded, usage %s/%s. | The quota of %s is exceeded, usage %s/%s. |
| 400 | UnsupportedFeature.ConnectionDrain | The feature of %s is not supported. | The feature of %s is not supported. |
| 400 | NotExist.ResourceGroup | ResourceGroup does not exist. | The resource group does not exist. |
| 400 | OperationDenied.VpcNotSupportIpv6 | The operation is not allowed because of VpcNotSupportIpv6. | The operation is not allowed because of VpcNotSupportIpv6. |
| 400 | UnsupportedFeature.FcServerGroup | Server groups of type FC are not supported. | Server groups of type FC are not supported |
| 404 | ResourceNotFound.Vpc | The specified resource %s is not found. | The VPC does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.