All Products
Search
Document Center

Server Load Balancer:CreateServerGroup

Last Updated:Oct 30, 2026

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

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

alb:CreateServerGroup

create

*ServerGroup

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

  • alb:ServerGroupProtocol
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 (default): server type. This type of server group supports adding Ecs, Eni, and Eci instances.

  • Ip: IP address type. This type of server group supports adding backend servers by IP address.

  • Fc: Function Compute type. This type of server group supports adding Function Compute backend servers.

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:

  • Wrr (default): weighted round-robin. Backend servers with higher weights are more likely to be polled.

  • Wlc: weighted least connections. In addition to polling based on the weight of each backend server, this algorithm also considers the actual load (number of connections) of the backend servers. When the weights are the same, backend servers with fewer current connections are more likely to be polled.

  • Sch: consistent hashing. Requests with the same hash factor calculation result are scheduled to the same backend server. If the UchConfig parameter is not configured, the default hash factor is the source IP address, and requests from the same source IP address are distributed to the same backend server. If the UchConfig parameter is configured, the hash factor is the URL parameter, and requests with the same URL parameter are distributed to the same backend server.

Note

This parameter takes effect only when ServerGroupType is set to Instance or Ip.

Wrr

Protocol

string

No

The backend protocol. Valid values:

  • HTTP (default): supports associating with HTTPS, HTTP, and QUIC listeners.

  • HTTPS: supports associating with HTTP and HTTPS listeners.

  • gRPC: associates with HTTPS listeners.

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:

  • true: enables health checks.

  • false: disables health checks.

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:

  • Internal IP address of the backend server (default): uses the internal IP address of the backend server as the domain name for health checks.

  • Custom domain name: specifies a domain name.

    • The domain name must be 1 to 80 characters in length.

    • It can contain lowercase letters, digits, hyphens (-), and periods (.).

    • It must contain at least one period (.), and the period (.) cannot be at the beginning or end.

    • The rightmost domain label can contain only letters, and cannot contain digits or hyphens (-).

    • The hyphen (-) cannot be at the beginning or end.

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.

  • When HealthCheckProtocol is set to HTTP or HTTPS, valid values for HealthCheckCodes are http_2xx (default), http_3xx, http_4xx, and http_5xx. Separate multiple status codes with commas (,).

  • When HealthCheckProtocol is set to gRPC, the valid values for HealthCheckCodes range from 0 to 99, and the default value is 0. You can specify ranges, and up to 20 ranges are supported. Separate multiple ranges with commas (,).

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:

  • GET: if the length of the response message exceeds 8 KB, it is truncated, but this does not affect the health check result.

  • POST: the default method for gRPC listener health checks.

  • HEAD (default): the default method for HTTP and HTTPS listener health checks.

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: -/.%?#&= and extended characters _;~!()*[]@$^:',+. The URL must start with a forward slash (/).

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: sends HEAD or GET requests to perform impersonation of browser access and check whether the server application is healthy.

  • HTTPS: sends HEAD or GET requests to perform impersonation of browser access and check whether the server application is healthy (data encryption, which makes it more secure than HTTP).

  • TCP: sends SYN handshake messages to check whether the server port is alive.

  • gRPC: sends POST or GET requests to check whether the server application is healthy.

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:

  • true: enables session persistence.

  • false: disables session persistence.

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:

  • Insert (default): inserts a cookie. When a client accesses the server for the first time, load balancing inserts a cookie (that is, inserts SERVERID into the HTTP or HTTPS response message). The next time the client accesses the server with this cookie, load balancing forwards the request to the previously recorded backend server.

  • Server: rewrites a cookie. When load balancing detects a user-defined cookie, it rewrites the original cookie. The next time the client accesses the server with the new cookie, load balancing forwards the request to the previously recorded backend server.

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:

  • true: prechecks the request without creating the server group. The system checks whether the required parameters are specified, the request format, and the service limits. If the request fails the precheck, the corresponding error is returned. If the request passes the precheck, the DryRunOperation error code is returned.

  • false (default): sends the normal request. After the request passes the precheck, an HTTP 2xx status code is returned and the operation is performed.

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:

  • false (default): IPv6 is not supported. The IPv4 type supports adding only IPv4 backend servers.

  • true: the dual-stack type is used. Both IPv4 and IPv6 backend servers can be added.

true

UpstreamKeepaliveEnabled

boolean

No

Specifies whether to enable backend keep-alive. Valid values:

  • true: enables backend keep-alive.

  • false (default): disables backend keep-alive.

false

ServiceName

string

No

The name of the K8s Service that corresponds to the server group. This parameter is applicable only to ALB Ingress scenarios.

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
  • Basic Edition instances do not support graceful connection break. Only Standard Edition and WAF-enhanced Edition instances support this feature.

  • Server type and IP type server groups support graceful connection break. Function Compute type server groups do not support this feature.

ConnectionDrainEnabled

boolean

No

Specifies whether to enable connection draining. Valid values:

  • true: enables connection draining.

  • false: disables connection draining (default).

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
  • Basic Edition instances do not support slow start. Only Standard Edition and WAF-enhanced Edition instances support this feature.

  • Server type and IP backend server groups support slow start. Function Compute backend server groups do not support this feature.

  • Slow start can be enabled only when the backend scheduling algorithm is weighted round-robin.

SlowStartEnabled

boolean

No

Specifies whether to enable slow start. Valid values:

  • true: enables slow start.

  • false: disables slow start (default).

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 aliyun or acs:, or contain http:// or https://.

env

Value

string

No

The tag value. The value can be up to 128 characters in length, and cannot start with aliyun or acs:, or contain http:// or https://.

product

CrossZoneEnabled

boolean

No

Specifies whether to enable cross-zone load balancing for the server group. Valid values:

  • true: enables cross-zone load balancing (default).

  • false: disables cross-zone load balancing.

Note
  • Basic Edition instances do not support associating with server groups that have cross-zone load balancing disabled. Only Standard Edition and WAF-enhanced Edition instances support this feature.

  • Server type and IP type server groups support disabling cross-zone load balancing. Function Compute type server groups do not support this feature.

  • Session persistence cannot be enabled when cross-zone load balancing is disabled.

true

IpVersionAffinityMode

string

No

The IP version affinity mode. Valid values:

  • NonAffinity: non-affinity mode. This is the default value.

  • Affinity: affinity mode.

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.