All Products
Search
Document Center

Server Load Balancer:CreateServerGroup

Last Updated:Jan 21, 2026

Creates a server group in a region.

Operation description

CreateServerGroup is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call ListServerGroups to query the status of a server group.

  • If a server group is in the Creating state, it indicates that the server group is being created.

  • If a server group is in the Available state, it indicates that 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 can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.

test

ServerGroupType

string

No

The type of server group. Valid values:

  • Instance (default): allows you to add servers by specifying Ecs, Eni, or Eci.

  • Ip: allows you to add servers by specifying IP addresses.

  • Fc: allows you to add servers by specifying functions of Function Compute.

Instance

VpcId

string

No

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

Note

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

vpc-bp15zdkdt37pq72zv****

Scheduler

string

No

The scheduling algorithm. Valid values:

  • Wrr (default): The weighted round-robin algorithm is used. Backend servers that have higher weights receive more requests than those that have lower weights.

  • Wlc: The weighted least connections algorithm is used. Requests are distributed based on the weights and the number of connections to backend servers. If two backend servers have the same weight, the backend server that has fewer connections is expected to receive more requests.

  • Sch: The consistent hashing algorithm is used. Requests from the same source IP address are distributed to the same backend server.

Note

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

Wrr

Protocol

string

No

The backend protocol. Valid values:

  • HTTP: allows you to associate an HTTPS, HTTP, or QUIC listener with the server group. This is the default value.

  • HTTPS: allows you to associate HTTPS listeners with backend servers.

  • gRPC: allows you to associate an HTTPS or QUIC listener with the server group.

Note

You do not need to specify a backend protocol if you set ServerGroupType to Fc.

HTTP

ResourceGroupId

string

No

The ID of the resource group.

rg-atstuj3rsop****

HealthCheckConfig

object

Yes

The configuration of the health check feature.

HealthCheckConnectPort

integer

No

The backend port that is used for health checks.

Valid values: 0 to 65535

The default value is 0, which specifies that the port of a backend server is used for health checks.

80

HealthCheckEnabled

boolean

Yes

Specifies whether to enable the health check feature. Valid values:

  • true

  • false

Note

If the ServerGroupType parameter is set to Instance or Ip, the health check feature is enabled by default. If the ServerGroupType parameter is set to Fc, the health check feature is disabled by default.

true

HealthCheckHost

string

No

The domain name that is used for health checks.

  • Backend Server Internal IP (default): Use the internal IP address of backend servers as the health check domain name.

  • Custom Domain Name: Enter a domain name.

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

    • The domain name can contain lowercase letters, digits, hyphens (-), and periods (.).

    • The domain name must contain at least one period (.) but cannot start or end with a period (.).

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

    • The domain name cannot start or end with a hyphen (-).

Note

This parameter takes effect only if HealthCheckProtocol is set to HTTP, HTTPS, or gRPC.

www.example.com

HealthCheckCodes

array

No

The HTTP status code that indicates healthy backend servers.

string

No

The HTTP status code that indicates healthy backend servers.

  • When HealthCheckProtocol is set to HTTP or HTTPS, you can set HealthCheckCodes to http_2xx (default value), http_3xx, http_4xx, and http_5xx. Separate multiple HTTP status codes with commas (,).

  • If HealthCheckProtocol is set to gRPC, the valid values for HealthCheckCodes are from 0 to 99. The default value is 0. Value ranges are supported. You can specify at most 20 value ranges. Separate multiple value ranges with commas (,).

Note

This parameter takes effect only if HealthCheckProtocol is set to HTTP, HTTPS, or gRPC.

http_2xx

HealthCheckHttpVersion

string

No

The version of the HTTP protocol. Valid values: HTTP1.0 and HTTP1.1. Default value: HTTP1.1.

Note

This parameter takes effect only if HealthCheckProtocol is set to HTTP or HTTPS.

HTTP1.1

HealthCheckInterval

integer

No

The interval at which health checks are performed. Unit: seconds

Valid values: 1 to 50

Default value: 2.

2

HealthCheckMethod

string

No

The HTTP method that is used for health checks. Valid values:

  • GET: If the length of a response exceeds 8 KB, the response is truncated. However, the health check result is not affected.

  • POST: By default, gRPC health checks use the POST method.

  • HEAD (default): By default, HTTP and HTTPS use the HEAD method.

Note

This parameter takes effect only if HealthCheckProtocol is set to HTTP, HTTPS, or gRPC.

HEAD

HealthCheckPath

string

No

The URL that is used for health checks.

The URL 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 takes effect only if HealthCheckProtocol is set to HTTP or HTTPS.

/test/index.html

HealthCheckProtocol

string

No

The protocol that is used for health checks. Valid values:

  • HTTP: HTTP health checks simulate browser behaviors by sending HEAD or GET requests to probe the availability of backend servers.

  • HTTPS: HTTPS health checks simulate browser behaviors by sending HEAD or GET requests to probe the availability of backend servers. HTTPS provides higher security than HTTP because HTTPS supports data encryption.

  • TCP: TCP health checks send TCP SYN packets to a backend server to probe the availability of backend servers.

  • gRPC: gRPC health checks send POST or GET requests to a backend server to check whether the backend server is healthy.

HTTP

HealthCheckTimeout

integer

No

The timeout period of a health check response. If a backend server does not respond within the specified timeout period, the backend server is declared unhealthy. Unit: seconds

Valid values: 1 to 300

Default value: 5

5

HealthyThreshold

integer

No

The number of times that an unhealthy backend server must consecutively pass health checks before it is declared healthy. In this case, the health check status of the backend server changes from fail to success.

Valid values: 2 to 10

Default value: 3.

3

UnhealthyThreshold

integer

No

The number of times that a healthy backend server must consecutively fail health checks before it is declared unhealthy. In this case, the health check status of the backend server changes from success to fail.

Valid values: 2 to 10

Default value: 3

3

StickySessionConfig

object

No

The configuration of session persistence.

Note

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

Cookie

string

No

The cookie that you want to configure for 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 space characters. It 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 maximum amount of time to wait before the session cookie expires. 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

  • false

Note

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

false

StickySessionType

string

No

The method that is used to handle cookies. Valid values:

  • Insert (default value): inserts a cookie. The first time a client accesses ALB, ALB inserts the SERVERID cookie into the HTTP or HTTPS response packet. Subsequent requests from the client that carry this cookie are forwarded to the same backend server as the first request.

  • Server: rewrites a cookie. ALB rewrites the custom cookies in requests from a client. Subsequent requests from the client that carry the new cookie are forwarded to the same backend server as the first request.

Note

This parameter takes effect when the StickySessionEnabled parameter 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 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 request ID as the client token. The request ID may be different for each request.

5A2CAF0E-5718-45B5-9D4D-70B******

DryRun

boolean

No

Specifies whether to perform only a dry run, without performing the actual request. Valid values:

  • true: performs only a dry run. The system checks the request for potential issues, including missing parameter values, incorrect request syntax, and service limits. If the request fails the dry run, an error code is returned. If the request passes the dry run, the DryRunOperation error code is returned.

  • false (default): performs a dry run and performs the actual request. If the request passes the dry run, a 2xx HTTP status code is returned and the operation is performed.

false

Ipv6Enabled

boolean

No

Specifies whether to enable Ipv6.

false

UpstreamKeepaliveEnabled

boolean

No

Specifies whether to enable persistent TCP connections.

false

ServiceName

string

No

This parameter is available only if the ALB Ingress controller is used. In this case, set this parameter to the name of the Kubernetes Service that is associated with the server group.

test

UchConfig

object

No

The configuration of consistent hashing based on URLs.

Type

string

Yes

The type of the parameter.

QueryString

Value

string

Yes

The parameter value for consistent hashing.

abc

ConnectionDrainConfig

object

No

The configurations of connection draining.

After connection draining is enabled, ALB maintains data transmission for a period of time after the backend server is removed or declared unhealthy.

Note
  • Basic ALB instances do not support connection draining. Standard and WAF-enabled ALB instances support connection draining.

  • Server groups of the instance and IP types support connection draining. Server groups of the Function Compute type do not support connection draining.

ConnectionDrainEnabled

boolean

No

Specifies whether to enable connection draining. Valid values:

  • true

  • false (default)

false

ConnectionDrainTimeout

integer

No

The timeout period of connection draining.

Valid values: 0 to 900.

Default value: 300.

300

SlowStartConfig

object

No

The configurations of slow starts. After slow starts are enabled, SLB prefetches data to newly added backend servers. Requests distributed to the backend servers gradually increase.

Note
  • Basic SLB instances do not support slow starts. Standard and WAF-enabled SLB instances support slow starts.

  • Server groups of the server and IP types support slow starts. Server groups of the Function Compute type do not support slow starts.

  • Slow start is supported only by the weighted round-robin scheduling algorithm.

SlowStartEnabled

boolean

No

Specifies whether to enable slow starts. Valid values:

  • true

  • false(default)

false

SlowStartDuration

integer

No

The duration of a slow start. Valid values: 30 to 900. Default value: 30.

30

Tag

array<object>

No

The tag.

object

No

Key

string

No

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

env

Value

string

No

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

product

CrossZoneEnabled

boolean

No

Specifies whether to enable cross-zone load balancing. Valid values:

  • true (default)

  • false

Note
  • Basic ALB instances do not support server groups that have cross-zone load balancing disabled. Only Standard and WAF-enabled ALB instances support server groups that have cross-zone load balancing.

  • Cross-zone load balancing can be disabled for server groups of the server and IP type, but not for server groups of the Function Compute type.

  • When cross-zone load balancing is disabled, session persistence cannot be enabled.

true

Response elements

Element

Type

Description

Example

object

The response parameters.

JobId

string

The ID of the asynchronous job.

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

RequestId

string

The request ID.

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