Create a server group in the specified region.
Operation description
The CreateServerGroup API is asynchronous. After you send a request, the system returns a request ID but the server group is still being created in the background. You can call the ListServerGroups operation to query the status of the server group.
If the server group is in the Creating state, it is being created.
If the server group is in the Available state, it 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, start with a letter, digit, or Chinese character, and 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 ID of the VPC where the server group is created. You can add only servers within this VPC to the server group. Note
This parameter is valid only when ServerGroupType is set to Instance or Ip. |
vpc-bp15zdkdt37pq72zv**** |
| Scheduler |
string |
No |
The scheduling algorithm. Valid values:
Note
This parameter is valid 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 this parameter if ServerGroupType is set to Fc. |
HTTP |
| ResourceGroupId |
string |
No |
The ID of the resource group. |
rg-atstuj3rsop**** |
| HealthCheckConfig |
object |
Yes |
The health check settings. |
rg-123 |
| HealthCheckConnectPort |
integer |
No |
The port on the backend server that is used for health checks. Valid values: 0 to 65535. Default value: 0. A value of 0 indicates that the backend server's traffic port is used for health checks. |
80 |
| HealthCheckEnabled |
boolean |
Yes |
Specifies whether to enable the health check feature. Valid values:
Note
If ServerGroupType is set to Instance or Ip, health checks are enabled by default. If ServerGroupType is set to Fc, health checks are disabled by default. |
true |
| HealthCheckHost |
string |
No |
The domain name that is used for health checks.
Note
This parameter is valid only when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC. |
www.example.com |
| HealthCheckCodes |
array |
No |
The HTTP status codes that indicate a successful health check. |
|
|
string |
No |
The HTTP status code for a successful health check.
Note
This parameter is valid only when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC. |
http_2xx |
|
| HealthCheckHttpVersion |
string |
No |
The HTTP version that is used for health checks. Valid values: HTTP1.0 and HTTP1.1. Default value: HTTP1.1. Note
This parameter is valid only when HealthCheckProtocol is set to HTTP or HTTPS. |
HTTP1.1 |
| HealthCheckInterval |
integer |
No |
The interval between health checks, in seconds. Valid values: 1 to 50. Default value: 2. |
2 |
| HealthCheckMethod |
string |
No |
The HTTP method that is used for health checks. Valid values:
Note
This parameter is valid only when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC. |
HEAD |
| HealthCheckPath |
string |
No |
The path for health checks. The path must be 1 to 80 characters in length. It must start with a forward slash (/) and can contain letters, digits, and the following special characters: Note
This parameter is valid only when HealthCheckProtocol is set to HTTP or HTTPS. |
/test/index.html |
| HealthCheckProtocol |
string |
No |
The protocol that is used for health checks. Valid values:
|
HTTP |
| HealthCheckTimeout |
integer |
No |
The timeout for a health check response, in seconds. If a backend server does not respond within this time, the health check fails. Valid values: 1 to 300. Default value: 5. |
5 |
| HealthyThreshold |
integer |
No |
The number of consecutive successful health checks that an unhealthy backend server must pass to be considered healthy. Valid values: 2 to 10. Default value: 3. |
3 |
| UnhealthyThreshold |
integer |
No |
The number of consecutive failed health checks that a healthy backend server must have to be considered unhealthy. Valid values: 2 to 10. Default value: 3. |
3 |
| StickySessionConfig |
object |
No |
The sticky session settings. Note
This parameter is valid only when ServerGroupType is set to Instance or Ip. |
|
| Cookie |
string |
No |
The cookie that is 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. It cannot start with a dollar sign ($). Note
This parameter is required if 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 is required if StickySessionEnabled is set to true and StickySessionType is set to Insert. |
1000 |
| StickySessionEnabled |
boolean |
No |
Specifies whether to enable sticky sessions. Valid values:
Note
This parameter is valid only when ServerGroupType is set to Instance or Ip. |
false |
| StickySessionType |
string |
No |
The method that is used to manage cookies. Valid values:
Note
This parameter is required if StickySessionEnabled is set to true. |
Insert |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotency of the request. You can use the client to generate a token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters. Note
If you do not specify this parameter, the system automatically uses the RequestId of the request as the ClientToken. The RequestId of each request may be different. |
5A2CAF0E-5718-45B5-9D4D-70B****** |
| DryRun |
boolean |
No |
Specifies whether to perform a dry run. Valid values:
|
false |
| Ipv6Enabled |
boolean |
No |
Specifies whether to enable IPv6. |
true |
| UpstreamKeepaliveEnabled |
boolean |
No |
Specifies whether to enable upstream keep-alive.
|
false |
| ServiceName |
string |
No |
This parameter is available only in ALB Ingress scenarios. It specifies the name of the Kubernetes |
test |
| UchConfig |
object |
No |
The settings for URL-based consistent hashing. |
|
| Type |
string |
Yes |
The type of the parameter. Set the value to QueryString. |
QueryString |
| Value |
string |
Yes |
The key of the query string parameter that is used for consistent hashing. |
abc |
| ConnectionDrainConfig |
object |
No |
The settings for connection draining. If you enable connection draining, the load balancer allows existing connections to be processed for a specified period of time after a backend server is removed or becomes unhealthy. Note
|
|
| ConnectionDrainEnabled |
boolean |
No |
Specifies whether to enable connection draining.
|
false |
| ConnectionDrainTimeout |
integer |
No |
The timeout period for connection draining, in seconds. Valid values: 0 to 900. Default value: 300. |
300 |
| SlowStartConfig |
object |
No |
The slow start settings. If you enable slow start, requests are gradually and linearly routed to a newly added backend server over a specified period of time. Note
|
|
| SlowStartEnabled |
boolean |
No |
Specifies whether to enable slow start.
|
false |
| SlowStartDuration |
integer |
No |
The duration of the slow start period, in seconds. Valid values: 30 to 900. Default value: 30. |
30 |
| Tag |
array<object> |
No |
The tags. |
|
|
object |
No |
A tag. |
||
| 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 of the server group. |
Affinity |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The data returned. |
||
| JobId |
string |
The asynchronous task ID. |
72dcd26b-f12d-4c27-b3af-18f6aed5**** |
| RequestId |
string |
The request ID. |
365F4154-92F6-4AE4-92F8-7FF****** |
| ServerGroupId |
string |
The server group ID. |
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. | |
| 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. | |
| 400 | OperationDenied.VpcNotSupportIpv6 | The operation is not allowed because of VpcNotSupportIpv6. | This operation is not allowed because the IPv6 function is not enabled for the current VPC. |
| 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. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.