Creates a server group.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateServerGroup

The operation that you want to perform. Set the value to CreateServerGroup.

ServerGroupName String No sg-atstuj3rtoptyui****

The name of the server group. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.

VpcId String No vpc-bp15zckdt37pq72zv****

The ID of the virtual private cloud (VPC). You can add only servers that are deployed in the specified VPC to the server group.

Scheduler String No Wrr

The scheduling algorithm. Valid values:

  • Wrr: Backend servers that have higher weights receive more requests than those that have lower weights. This is the default value.
  • Wlc: Requests are distributed based on the weights and number of connections to backend servers. If two backend servers have the same weight, the backend server that has fewer connections receives more requests.
  • Sch: specifies consistent hashing that is based on source IP addresses.
Protocol String No HTTP

The server protocol. Valid values:

  • HTTP (default): If you select this option, you can associate the servers with HTTPS, HTTP or QUIC listeners.
  • HTTPS: If you select this option, you can associate the servers with HTTPS listeners.
ResourceGroupId String No rg-atstuj3rtop****

The ID of the resource group.

HealthCheckConfig Object Yes

The configurations of health checks.

HealthCheckConnectPort Integer No 80

The port of the backend server that is used for health checks.

Valid values: 0 to 65535.

Default value: 0. This value indicates that the backend server is used for health checks.

HealthCheckEnabled Boolean No true

Specifies whether to enable health checks. Valid values:

  • true: (default) enables health checks.
  • false: disables health checks
HealthCheckHost String No www.test.com

The domain name that is used for health checks. The domain name must meet the following requirements:

  • The domain name must be 1 to 80 characters in length,
  • and can contain letters, digits, hyphens (-), and periods (.).
  • It must contain at least one period (.), and cannot start or end with a period (.).
  • The rightmost region label can contain only letters, and cannot contain digits or hyphens (-).
  • Other region labels cannot start or end with a hyphen (-).
Note This parameter is required if the HealthCheckProtocol parameter is set to HTTP.
HealthCheckCodes Array of String No 200

The status code for a successful health check. Multiple status codes can be specified as a list.

Note If HealthCheckProtocol is set to HTTP, this parameter is valid.

Valid values: http_2xx, http_3xx, http_4xx, and http_5xx. Default value: http_2xx.

HealthCheckHttpVersion String No HTTP1.0

The HTTP protocol version. Valid values: HTTP1.0 and HTTP1.1 (default).

Note This parameter is valid if the HealthCheckProtocol parameter is set to HTTP.
HealthCheckInterval Integer No 5

The time interval between two consecutive health checks. Unit: seconds.

Valid values: 1 to 50.

Default value: 2.

HealthCheckMethod String No HEAD

Health check method. Valid values:GET and HEAD (default).

Note This parameter is valid if the HealthCheckProtocol parameter is set to HTTP.
HealthCheckPath String No /test/index.html

The forwarding rule path of health checks.

The value must be 1 to 80 characters in length, and can contain letters, digits, and the following special characters: - / . %?# & =. It can also contain the following extended characters: _ ; ~ ! ( ) * [ ] @ $ ^ : ' , +. The URL must start with a forward slash (/).

Note This parameter is valid if the HealthCheckProtocol parameter is set to HTTP.
HealthCheckProtocol String No HTTP

The protocol used for health checks. Valid values: HTTP and HTTPS.

HealthCheckTimeout Integer No 3

The timeout period of a health check response. If a backend Elastic Compute Service (ECS) instance does not send an expected response within the specified period of time, the ECS instance is considered unhealthy. Unit: seconds.

Valid values: 1 to 300.

Default value: 5.

Note If the value of the HealthCheckTimeout parameter is smaller than that of the HealthCheckInterval parameter, the value of the HealthCheckTimeout parameter is ignored and the value of the HealthCheckInterval parameter is regarded as the timeout period.
HealthyThreshold Integer No 4

The number of health checks that an unhealthy backend server must consecutively pass before it is declared healthy (from fail to success).

Valid values: 2 to 10.

Default value: 3.

UnhealthyThreshold Integer No 4

The number of health checks that a healthy backend server must consecutively fail before it is declared unhealthy (from success to fail).

Valid values: 2 to 10.

Default value: 3.

StickySessionConfig Object No

The configuration of the sticky session.

Cookie String No B490B5EBF6F3CD402E515D22BCDA****

The cookie that is configured on the server.

The value must be 1 to 200 characters in length, and can contain only ASCII characters and digits. It cannot contain commas (,), semicolons (;), or spaces. It cannot start with a dollar sign ($).

Note If you set the StickySession parameter to on and the StickySessionType parameter to server, this parameter is required.
CookieTimeout Integer No 1000

The timeout period of a cookie. Unit: seconds.

Valid values: 1 to 86400.

Default value: 1000.

Note This parameter is valid if the StickySessionEnabled parameter is set to true and the StickySessionType parameter is set to Insert.
StickySessionEnabled Boolean No true

Specifies whether to enable sticky session. Valid values: true and false (default).

StickySessionType String No Insert

The method that is used to handle a cookie. Valid values:

  • Insert (default): inserts a cookie.

    Application Load Balancer (ALB) inserts a cookie (SERVERID) into the first HTTP or HTTPS response packet that is sent to a client. The next request from the client contains this cookie and the listener distributes this request to the recorded backend server.

  • Server: rewrites a cookie.

    When ALB detects a user-defined cookie, it overwrites the original cookie with the user-defined cookie. The next request from the client will contain the user-defined cookie, and the listener will distribute the request to the recorded backend server.

Note This parameter is valid if the StickySession parameter is set to On.
ClientToken String No 5A2CFF0E-5718-45B5-9D4D-70B3FF3898

The client token that is used to ensure the idempotency of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.

Note If you do not set this parameter, the system automatically uses the request ID as the client token. The ID of each request may be unique.
DryRun Boolean No true

Specify whether to precheck this request. Valid values:

  • true: prechecks the API request. Resources are not created. The system checks the required parameters, request format and service limits. If the request fails the check, the corresponding error message is returned. If the request passes the precheck, the DryRunOperation error code is returned.
  • false: sends the request. This is the default value. If the request passes the precheck, a 2XX HTTP status code is returned and the operation is performed.

Response parameters

Parameter Type Example Description
JobId String 72dcd26b-f12d-4c27-b3af-18f6aed5****

The ID of the query task.

RequestId String 365F4154-92F6-4AE4-92F8-7FF34B540710

The ID of the request.

ServerGroupId String sg-atstuj3rtoptyui****

The ID of the server group.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateServerGroup
&ServerGroupName=sg-atstuj3rtoptyui****
&VpcId=vpc-bp15zckdt37pq72zv****
&Scheduler=Wrr
&Protocol=HTTP
&ResourceGroupId=rg-atstuj3rtop****
&HealthCheckConfig={"HealthCheckConnectPort":80,"HealthCheckEnabled":true,"HealthCheckHost":"www.test.com","HealthCheckCodes":["200"],"HealthCheckHttpVersion":"HTTP1.0","HealthCheckInterval":5,"HealthCheckMethod":"HEAD","HealthCheckPath":"/test/index.html","HealthCheckProtocol":"HTTP","HealthCheckTimeout":3,"HealthyThreshold":4,"UnhealthyThreshold":4}
&StickySessionConfig={"Cookie":"B490B5EBF6F3CD402E515D22BCDA****","CookieTimeout":1000,"StickySessionEnabled":true,"StickySessionType":"Insert"}
&ClientToken=5A2CFF0E-5718-45B5-9D4D-70B3FF3898
&DryRun=true
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateServerGroupResponse>
    <JobId>72dcd26b-f12d-4c27-b3af-18f6aed5****</JobId>
    <RequestId>365F4154-92F6-4AE4-92F8-7FF34B540710</RequestId>
    <ServerGroupId>sg-atstuj3rtoptyui****</ServerGroupId>
</CreateServerGroupResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "JobId" : "72dcd26b-f12d-4c27-b3af-18f6aed5****",
  "RequestId" : "365F4154-92F6-4AE4-92F8-7FF34B540710",
  "ServerGroupId" : "sg-atstuj3rtoptyui****"
}

Error codes

HttpCode Error code Error message Description
400 QuotaExceeded.ServerGroupsNum The quota of %s is exceeded, usage %s/%s. The error message returned because the usage %s has reached the upper limit %s.

For a list of error codes, visit the API Error Center.