Creates a server group in a specified region.
Operation description
The CreateServerGroup operation is asynchronous. After a request is sent, the system returns a request ID. However, the server group is not yet created. The creation task continues to run in the background. You can call ListServerGroups 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 server group name. The name must be 2 to 128 characters in length, and must start with an uppercase letter, lowercase letter, Chinese character, or digit. The name 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 resource group ID. |
rg-atstuj3rsop**** |
| HealthCheckConfig |
object |
Yes |
The health check configurations. |
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
Health checks are enabled by default when ServerGroupType is set to Instance or Ip. Health checks are disabled by default when ServerGroupType is set to Fc. |
true |
| HealthCheckHost |
string |
No |
The domain name used for health checks.
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 Normal health check status. |
|
|
string |
No |
The status code that indicates a Normal health check status.
Note
This parameter takes effect when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC. |
http_2xx |
|
| HealthCheckHttpVersion |
string |
No |
The HTTP version 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 health check method. Valid values:
Note
This parameter takes effect only when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC. |
HEAD |
| HealthCheckPath |
string |
No |
The forwarding rule path for health checks. The path must be 1 to 80 characters in length and can contain only letters, digits, and the characters Note
This parameter takes effect only when HealthCheckProtocol is set to HTTP or HTTPS. |
/test/index.html |
| HealthCheckProtocol |
string |
No |
The health check protocol. Valid values:
|
HTTP |
| HealthCheckTimeout |
integer |
No |
The maximum period of time to wait for a response from a health check. If the backend server does not respond correctly within the specified period of time, 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 before the health check status of a backend server changes from fail to success. Valid values: 2 to 10. Default value: 3. |
3 |
| UnhealthyThreshold |
integer |
No |
The number of consecutive failed health checks required before the health check status of a backend server changes from success to fail. 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 when StickySessionEnabled is set to true and StickySessionType is set to server. |
B490B6EBF6F3CD402E515D22BCDA**** |
| CookieTimeout |
integer |
No |
The cookie timeout period. Unit: seconds. Valid values: 1 to 86400. Default value: 1000. Note
This parameter takes effect 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 when StickySessionEnabled is set to true. |
Insert |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotence of the request. Generate a parameter value from your client to ensure that the value is unique among different requests. ClientToken supports only ASCII characters. Note
If you do not specify this parameter, the system uses the RequestId of the API request as the ClientToken. The RequestId may vary for each API request. |
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 keepalive connections.
|
false |
| ServiceName |
string |
No |
This parameter is applicable only to ALB Ingress scenarios and specifies 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 connection draining configuration. After connection draining is enabled, when a backend server is removed or a health check failure occurs, the load balancing service allows existing connections to continue Normal data transmission for a specified period of time. Note
|
|
| ConnectionDrainEnabled |
boolean |
No |
Specifies whether to enable connection draining.
|
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 are warmed up during a specified period of time. The number of requests forwarded to the server increases linearly. Note
|
|
| SlowStartEnabled |
boolean |
No |
Specifies whether to enable slow start.
|
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 tag key can be up to 128 characters in length, and cannot start with |
env |
| Value |
string |
No |
The tag value. The tag 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. |
Affinity |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response struct. |
||
| 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. | The %s feature 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.