CreateServerGroup

更新时间:
复制 MD 格式

Creates a server group in a specified region.

Operation description

CreateServerGroup is an asynchronous operation. After you send a request, the system returns a request ID. The server group for the Network Load Balancer (NLB) instance is created in the background. You can call the GetJobStatus operation to query the creation status of the server group:

  • If the task status is Succeeded, the server group is created.

  • If the task status is Processing, the server group is being created. In this state, you can only perform query operations.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

nlb:CreateServerGroup

create

*ServerGroup

acs:nlb:{#regionId}:{#accountId}:servergroup/*

*VPC

acs:vpc:{#regionId}:{#accountId}:vpc/{#VpcId}

None None

Request parameters

Parameter

Type

Required

Description

Example

ServerGroupType

string

No

The type of the server group. Valid values:

  • Instance (default): a server group of the instance type. This type of server group lets you add Elastic Compute Service (ECS) instances, elastic network interfaces (ENIs), and elastic container instances (ECIs).

  • Ip: a server group of the IP address type. This type of server group lets you add backend servers by specifying their IP addresses.

Instance

ServerGroupName

string

Yes

The name of the server group.

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

NLB_ServerGroup

AddressIPVersion

string

No

The IP version. Valid values:

  • ipv4 (default): IPv4.

  • DualStack: dual-stack.

ipv4

Protocol

string

No

The traffic scheduling policy for dual-stack mode. Valid values:

  • NonAffinity (default): Requests are forwarded to healthy backend servers based on the scheduling algorithm, regardless of the source IP version.

  • Affinity: Requests are forwarded based on the source IP version. IPv4 requests are forwarded only to IPv4 backend servers. IPv6 requests are forwarded only to IPv6 backend servers.

Note

This parameter applies only when AddressIPVersion is set to DualStack.

TCP

VpcId

string

Yes

The protocol for forwarding requests to the backend servers. Valid values:

  • TCP (Default)

  • UDP

  • TCP_UDP

Note
  • If this parameter is set to UDP, the server group supports only UDP listeners.

  • If this parameter is set to TCP and PreserveClientIpEnabled is set to true, the server group supports only TCP listeners.

  • If this parameter is set to TCP and PreserveClientIpEnabled is set to false, the server group supports both TCPSSL and TCP listeners.

  • If this parameter is set to TCP_UDP, the server group supports both TCP and UDP listeners.

vpc-bp15zckdt37pq72zv****

AnyPortEnabled

boolean

No

The ID of the VPC where the server group is located.

Note

If ServerGroupType is set to Instance, only servers in this VPC can be added to the server group.

false

ConnectionDrainEnabled

boolean

No

Specifies whether to enable all-port forwarding. Valid values:

  • true

  • false (default)

false

ConnectionDrainTimeout

integer

No

Specifies whether to enable connection draining. Valid values:

  • true: Enable.

  • false (default): Disable.

10

Scheduler

string

No

The connection draining timeout, in seconds. The value must be from 0 to 900.

Wrr

PreserveClientIpEnabled

boolean

No

The scheduling algorithm. Valid values:

  • Wrr (default): weighted round-robin. Backend servers with higher weights receive more requests.

  • Wlc: weighted least connections. This algorithm considers both the weight and the number of active connections for each backend server. If servers have the same weight, the one with the fewest connections receives the next request.

  • rr: round-robin. Requests are distributed to backend servers in sequence.

  • sch: source IP hash. Requests from the same source IP address are routed to the same backend server.

  • tch: four-tuple hash. This is a consistent hash based on a four-tuple (source IP address, destination IP address, source port, and destination port). Requests in the same stream are routed to the same backend server.

  • qch: QUIC ID hash. Requests with the same QUIC ID are hashed to the same backend server.

Note

QUIC ID hash is supported only when the backend protocol is UDP.

true

HealthCheckConfig

object

No

Specifies whether to enable client IP persistence. Valid values:

  • true (default): Enabled.

  • false: Disabled.

Note

If Protocol is set to TCP and this parameter is set to true, the server group cannot be associated with a TCPSSL listener.

HealthCheckEnabled

boolean

No

Specifies whether to enable health checks. Valid values: true (default) false

true

HealthCheckType

string

No

The health check protocol. Valid values: TCP HTTP UDP

TCP

HealthCheckConnectPort

integer

No

The port used for health checks on backend servers. Valid values: 0 to 65535. Default value: 0. A value of 0 means the port of a backend server is used for health checks.

0

HealthyThreshold

integer

No

The number of consecutive successful health checks required to change the health status of a backend server from failed to successful.Valid values: 2 to 10.Default value: 2.

2

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: 2.

2

HealthCheckConnectTimeout

integer

No

The maximum timeout period of a health check response. Unit: seconds. Valid values: 1 to 300. Default value: 5.

5

HealthCheckInterval

integer

No

The interval between two consecutive health checks. Unit: seconds. Default value: 5. If HealthCheckType is set to TCP or HTTP, the value must be in the range of 1 to 50. If HealthCheckType is set to UDP, the value must be in the range of 1 to 300. Set the interval to a value greater than or equal to the response timeout period. This prevents UDP probes from being marked as timed out.

5

HealthCheckDomain

string

No

The domain name that is used for health checks. Valid values: $SERVER_IP: the private IP address of a backend server. domain: a specific domain name. The domain name must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), and periods (.). This parameter takes effect only when HealthCheckType is set to HTTP.

$SERVER_IP

HealthCheckUrl

string

No

The path that is used for health checks. The path must be 1 to 80 characters in length. It can contain letters, digits, and the following special characters: -/.%?#&. It must start with a forward slash (/). This parameter takes effect only when HealthCheckType is set to HTTP.

/test/index.html

HealthCheckHttpCode

array

No

The HTTP status codes that indicate a healthy backend server. Separate multiple HTTP status codes with commas (,). Valid values: http_2xx (default), http_3xx, http_4xx, and http_5xx. This parameter takes effect only when HealthCheckType is set to HTTP.

string

No

The HTTP status codes that indicate a healthy backend server. Separate multiple HTTP status codes with commas (,). Valid values: http_2xx (default), http_3xx, http_4xx, and http_5xx. This parameter takes effect only when HealthCheckType is set to HTTP.

http_2xx

HttpCheckMethod

string

No

The HTTP method used for health checks. Valid values: GET (default) and HEAD. This parameter takes effect only when HealthCheckType is set to HTTP.

GET

HealthCheckReq

string

No

The request string for UDP health checks. The string can contain only letters and digits. The maximum length is 512 characters.

hello

HealthCheckExp

string

No

The expected response string for UDP health checks. The string must be alphanumeric and have a maximum length of 512 characters.

ok

HealthCheckHttpVersion

string

No

The version of the HTTP protocol. Valid values: HTTP1.0 (default) and HTTP1.1. This parameter takes effect only when HealthCheckType is set to HTTP.

HTTP1.0

ResourceGroupId

string

No

The health check configuration.

rg-atstuj3rtop****

DryRun

boolean

No

The ID of the resource group to which the server group belongs.

true

ClientToken

string

No

Specifies whether to perform a dry run. Valid values:

  • true: Sends a check request without creating the server group. The system checks for required parameters, the request format, and service limits. If the request fails the check, the system returns an error. If the request passes the check, the system returns the DryRunOperation error code.

  • false (Default): Sends a normal request. If the request passes the check, the system returns an HTTP 2xx status code and creates the server group.

123e4567-e89b-12d3-a456-426655440000

RegionId

string

No

The client token used to ensure the idempotence of the request.

Generate a value from your client. Ensure that the value is unique for each request. The ClientToken parameter 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 is unique for each API request.

cn-hangzhou

Tag

array<object>

No

The ID of the region where the Network Load Balancer (NLB) instance is deployed.

Call the DescribeRegions operation to get the region ID.

object

No

The tag.

Key

string

No

The tag key. The key can be up to 64 characters in length. It cannot start with aliyun or acs:. It cannot contain http:// or https://. It can contain letters, digits, underscores (_), periods (.), colons (:), forward slashes (/), equal signs (=), plus signs (+), hyphens (-), and at signs (@). Add up to 20 tags in a single call.

env

Value

string

No

The value of the tag. The value can be up to 128 characters in length. It cannot start with `aliyun` or `acs:`. It cannot contain `http://` or `https://`. It can contain letters, digits, underscores (_), periods (.), colons (:), forward slashes (/), equal signs (=), plus signs (+), hyphens (-), and at signs (@). A single call can contain up to 20 tags.

product

IpVersionAffinityMode

string

No

The tags.

Affinity

Response elements

Element

Type

Description

Example

object

The server group is created.

RequestId

string

The request ID.

54B48E3D-DF70-471B-AA93-08E683A1B45

ServerGroupId

string

The server group ID.

sgp-atstuj3rtoptyui****

JobId

string

The ID of the asynchronous task.

72dcd26b-f12d-4c27-b3af-18f6aed5****

Examples

Success response

JSON format

{
  "RequestId": "54B48E3D-DF70-471B-AA93-08E683A1B45",
  "ServerGroupId": "sgp-atstuj3rtoptyui****",
  "JobId": "72dcd26b-f12d-4c27-b3af-18f6aed5****"
}

Error codes

HTTP status code

Error code

Error message

Description

400 IllegalParam.AnyPortServerGroupConflictWithHealthCheckConfig The param of AnyPortServerGroupConflictWithHealthCheckConfig is illegal.
400 IllegalParamFormat.ParseCreateRsPoolRequestFailed The param format of CreateRsPoolRequest is illegal. The param format of CreateRsPoolRequest is illegal.
400 IllegalParam.PreserveClientIpSwitch The param of PreserveClientIpSwitch is illegal.
400 OperationDenied.VpcNotSupportIpv6 The operation is not allowed because of VpcNotSupportIpv6. The VPC you are using does not support Ipv6.
400 IllegalParam.healthCheckDomain The parameter of healthCheckConfig.healthCheckDomain is illegal. The healthCheckDomain in the health check configuration is invalid. Check the input parameters.
400 OperationDenied.UidNotAllowQuic29 The operation is not allowed because of uid not allow quic29 version.
400 IlleagalParam.healthCheckUrl The parameter of healthCheckUrl in healthCheckConfig is illegal. The URL of the health check used in the health check setting is invalid.
400 IllegalParam.ServerGroupName The param of ServerGroupName is illegal.
400 DryRunOperation Request validation has been passed with DryRun flag set. Request validation has been passed with DryRun flag set.
400 MissingParam.%s The parameter of %s is missing.
400 IllegalParam.ConnectionDrainTimeout The param of ConnectionDrainTimeout is illegal. The parameter ConnectionDrainTimeout is invalid. Check the input parameters.
400 IllegalParam The param of %s is illegal.
400 SystemBusy System is busy, please try again later.
400 QuotaExceeded.QuotaInsufficient The quota of %s is exceeded, usage %s/%s. The quota is insufficient, currently used %s/%s. Please modify the quota size in the quota center.
403 Forbidden.NoPermission Authentication is failed for NoPermission. Authentication is failed for NoPermission.
404 ResourceNotFound.Vpc The specified resource of Vpc is not found. The specified VPC resource was not found. Please check the input parameters.
404 ResourceNotFound.ResourceGroup The param of resourceGroup not existed. The resource group does not exist.

See for a complete list.

Release notes

See Release Notes for a complete list.