All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ALB::ServerGroup

Last Updated:Apr 17, 2025

ALIYUN::ALB::ServerGroup is used to create a server group.

Syntax

{
  "Type": "ALIYUN::ALB::ServerGroup",
  "Properties": {
    "VpcId": String,
    "ResourceGroupId": String,
    "Scheduler": String,
    "StickySessionConfig": Map,
    "HealthCheckConfig": Map,
    "Protocol": String,
    "ServerGroupType": String,
    "ServerGroupName": String,
    "Tags": List,
    "ServiceName": String,
    "UpstreamKeepaliveEnabled": Boolean,
    "SlowStartConfig": Map,
    "ConnectionDrainConfig": Map,
    "UchConfig": Map,
    "CrossZoneEnabled": Boolean,
    "Ipv6Enabled": Boolean
  }
}

Properties

Property

Type

Required

Editable

Description

Constraint

HealthCheckConfig

Map

Yes

Yes

The configurations of health checks.

For more information, see HealthCheckConfig properties.

ServerGroupName

String

Yes

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 (-). It must start with a letter.

VpcId

String

No

No

The ID of the virtual private cloud (VPC).

You can add only servers that are deployed in the VPC to the server group.

Protocol

String

No

No

The backend protocol.

Valid values:

  • HTTP (default): allows you to associate an HTTPS, HTTP, or Quick UDP Internet Connections (QUIC) listener with the server group.

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

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

Note

You must set Protocol to HTTP when ServerGroupType is set to Fc.

ResourceGroupId

String

No

Yes

The ID of the resource group.

None.

Scheduler

String

No

Yes

The scheduling algorithm.

Valid values:

  • Wrr (default): weighted round-robin. Backend servers that have higher weights receive more requests than backend servers that have lower weights.

  • Wlc: weighted least connections. Requests are distributed based on the weights and number of connections to backend servers. If multiple backend servers have the same weight, the backend server that has the least connections receives more requests.

  • Sch: consistent hashing based on source IP addresses.

ServerGroupType

String

No

No

The type of the server group.

Valid values:

  • Instance (default): server.

  • Ip: IP address.

  • Fc: Function Compute function.

ServiceName

String

No

Yes

The name of the Kubernetes service that corresponds to the server group.

Note

This property is applicable only to scenarios in which Application Load Balancer (ALB) Ingresses are used.

StickySessionConfig

Map

No

Yes

The configurations of session persistence.

For more information, see StickySessionConfig properties.

Tags

List

No

Yes

The tags.

You can add up to 20 tags.

For more information, see Tags properties.

UpstreamKeepaliveEnabled

Boolean

No

Yes

Specifies whether to enable persistent TCP connections.

  • true

  • false (default)

SlowStartConfig

Map

No

Yes

The configurations of slow starts.

After slow starts are enabled, ALB prefetches data to newly added backend servers. Requests distributed to the backend servers gradually increase.

For more information, see the "SlowStartConfig properties" section of this topic.

Note
  • You can enable slow starts for Standard and Web Application Firewall (WAF)-enabled ALB instances but not for Basic ALB instances.

  • Slow starts are supported by server groups of the Instance and Ip types but not by server groups of the Fc type.

  • You can enable slow starts only when the weighted round-robin scheduling algorithm is used for backend servers.

ConnectionDrainConfig

Map

No

Yes

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

You can enable connection draining for Standard and WAF-enabled ALB instances but not for Basic ALB instances.

Connection draining is supported by server groups of the Instance and Ip types but not by server groups of the Fc type.

UchConfig

Map

No

Yes

The parameter configurations of consistent hashing based on URLs.

For more information, see the "UchConfig properties" section of this topic.

CrossZoneEnabled

Boolean

No

Yes

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

Valid values:

  • true (default)

  • false

Note
  • Server groups that have cross-zone load balancing disabled are supported by Standard and WAF-enabled ALB instances but not by Basic ALB instances.

  • You can disable cross-zone load balancing for server groups of the Instance and Ip types but not for server groups of the Fc type.

  • You cannot enable session persistence when cross-zone load balancing is disabled.

Ipv6Enabled

Boolean

No

No

Specifies whether to enable Ipv6.

None.

UchConfig syntax

"UchConfig": {
  "Type": String,
  "Value": String
}

UchConfig properties

Property

Type

Required

Editable

Description

Constraint

Type

String

Yes

No

The parameter type.

Set the value to QueryString.

Value

String

Yes

No

The value of the parameter used for consistent hashing.

None.

ConnectionDrainConfig syntax

"ConnectionDrainConfig": {
  "ConnectionDrainTimeout": Integer,
  "ConnectionDrainEnabled": Boolean
}

ConnectionDrainConfig properties

Property

Type

Required

Editable

Description

Constraint

ConnectionDrainTimeout

Integer

Yes

Yes

The timeout period of connection draining.

Valid values: 0 to 900.

Default value: 300.

ConnectionDrainEnabled

Boolean

Yes

Yes

Specifies whether to enable connection draining.

Valid values:

  • true

  • false

SlowStartConfig syntax

"SlowStartConfig": {
  "SlowStartDuration": Integer,
  "SlowStartEnabled": Boolean
}

SlowStartConfig properties

Property

Type

Required

Editable

Description

Constraint

SlowStartDuration

Integer

Yes

Yes

The duration of a slow start.

Valid values: 30 to 900.

Default value: 30.

SlowStartEnabled

Boolean

Yes

Yes

Specifies whether to enable slow starts.

Valid values:

  • true

  • false

StickySessionConfig syntax

"StickySessionConfig": {
  "Cookie": String,
  "CookieTimeout": Integer,
  "StickySessionType": String,
  "StickySessionEnabled": Boolean
}

StickySessionConfig properties

Property

Type

Required

Editable

Description

Constraint

Cookie

String

No

Yes

The cookie that you want to configure for the server.

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

Note

This property must be specified when StickySessionEnabled is set to true and StickySessionType is set to Server.

CookieTimeout

Integer

No

Yes

The timeout period of the cookie.

Valid values: 1 to 86400.

Default value: 1000.

Unit: seconds.

Note

This property must be specified when StickySessionEnabled is set to true and StickySessionType is set to Insert.

StickySessionEnabled

Boolean

No

Yes

Specifies whether to enable session persistence.

Valid values:

  • true

  • false

Note

This property must be specified when ServerGroupType is set to Instance or Ip.

StickySessionType

String

No

Yes

The method of handling the cookie.

Valid values:

  • Insert (default): inserts the cookie. ALB inserts the cookie SERVERID into the first HTTP or HTTPS response packet that is sent to a client. The next request from the client carries the cookie, and ALB forwards this request to the backend server that is associated with ALB.

  • Server: rewrites a cookie. When ALB detects a user-defined cookie, ALB uses the cookie to overwrite the original cookie. The next request from the client carries the user-defined cookie, and ALB forwards this request to the backend server that is associated with ALB.

Note

This property must be specified when StickySessionEnabled is set to true.

HealthCheckConfig syntax

"HealthCheckConfig": {
  "HealthCheckInterval": Integer,
  "HealthCheckConnectPort": Integer,
  "HealthCheckCodes": List,
  "UnhealthyThreshold": Integer,
  "HealthCheckMethod": String,
  "HealthCheckPath": String,
  "HealthCheckHost": String,
  "HealthyThreshold": Integer,
  "HealthCheckProtocol": String,
  "HealthCheckHttpVersion": String,
  "HealthCheckEnabled": Boolean,
  "HealthCheckTimeout": Integer
}

HealthCheckConfig properties

Property

Type

Required

Editable

Description

Constraint

HealthCheckEnabled

Boolean

Yes

Yes

Specifies whether to enable health checks.

Valid values:

  • true

  • false

HealthCheckCodes

List

No

Yes

The status codes for health checks.

Valid values:

  • http_2xx. This is the default value of HealthCheckCodes when HealthCheckProtocol is not set to gRPC.

  • http_3xx.

  • http_4xx.

  • http_5xx.

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

Note

HealthCheckCodes takes effect when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC.

HealthCheckConnectPort

Integer

No

Yes

The port that you want to use for health checks on backend servers.

Valid values: 0 to 65535.

Default value: 0. A value of 0 specifies that the port of a backend server is used for health checks.

HealthCheckHost

String

No

Yes

The domain name that you want to use for health checks.

The domain name must be 1 to 80 characters in length, and can contain lowercase letters, digits, hyphens (-), and periods (.).

Example: www.example.com.

Note

This property takes effect when HealthCheckProtocol is set to HTTP.

HealthCheckHttpVersion

String

No

Yes

The HTTP version that you want to use for health checks.

Valid values:

  • HTTP1.0

  • HTTP1.1 (default)

Note

This property takes effect when HealthCheckProtocol is set to HTTP.

HealthCheckInterval

Integer

No

Yes

The interval between two consecutive health checks.

Valid values: 1 to 50.

Default value: 2.

Unit: seconds.

HealthCheckMethod

String

No

Yes

The health check method.

Valid values:

  • GET.

  • HEAD (default).

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

Note

HealthCheckMethod takes effect only when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC.

HealthCheckPath

String

No

Yes

The path that you want to use for health checks.

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

Note

This property takes effect when HealthCheckProtocol is set to HTTP.

HealthCheckProtocol

String

No

Yes

The protocol that you want to use 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 check whether the ports of backend servers are reachable.

  • gRPC: gRPC health checks send POST or GET requests to probe the availability of backend servers.

HealthCheckTimeout

Integer

No

Yes

The timeout period for a health check response.

If a backend Elastic Compute Service (ECS) instance does not return a health check response within the specified timeout period, the instance fails the health check.

Valid values: 1 to 300.

Default value: 5.

Unit: seconds.

Note

If the value of HealthCheckTimeout is smaller than the value of HealthCheckInterval, the value of HealthCheckTimeout is ignored, and the value of HealthCheckInterval is used as the timeout period.

HealthyThreshold

Integer

No

Yes

The number of times that an unhealthy backend server must consecutively pass health checks before it is declared healthy.

Valid values: 2 to 10.

Default value: 3.

UnhealthyThreshold

Integer

No

Yes

The number of times that a healthy backend server must consecutively fail health checks before it is declared unhealthy.

Valid values: 2 to 10.

Default value: 3.

Tags syntax

"Tags": [
  {
    "Key": String,
    "Value": String
  }
]  

Tags properties

Property

Type

Required

Editable

Description

Constraint

Key

String

Yes

No

The key of the tag.

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

Value

String

No

No

The value of the tag.

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

Return values

Fn::GetAtt

  • ServerGroupId: the ID of the server group.

  • Arn: the Alibaba Cloud Resource Name (ARN).

Examples

Note

Change the values of masked parameters based on your business requirements.

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  VpcId:
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
    Type: String
    Label:
       
      en: Existing VPC Instance ID
Resources:
  ServerGroup:
    Type: ALIYUN::ALB::ServerGroup
    Properties:
      VpcId:
        Ref: VpcId
      StickySessionConfig:
        Cookie: B490B5EBF6F3CD402E515D22****
        CookieTimeout: 1000
        StickySessionEnabled: true
        StickySessionType: Insert
      HealthCheckConfig:
        HealthCheckConnectPort: 80
        HealthCheckEnabled: true
        HealthCheckHost: www.example.com
        HealthCheckCodes:
          - http_2xx
        HealthCheckHttpVersion: HTTP1.0
        HealthCheckInterval: 5
        HealthCheckMethod: HEAD
        HealthCheckPath: /test/index.html
        HealthCheckProtocol: HTTP
        HealthCheckTimeout: 3
        HealthyThreshold: 4
        UnhealthyThreshold: 4
      ServerGroupName: TestServerGroup
Outputs:
  ServerGroupId:
    Description: The ID of the server group.
    Value:
      Fn::GetAtt:
        - ServerGroup
        - ServerGroupId                  

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "VpcId": {
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId",
      "Type": "String",
      "Label": {
         
        "en": "Existing VPC Instance ID"
      }
    }
  },
  "Resources": {
    "ServerGroup": {
      "Type": "ALIYUN::ALB::ServerGroup",
      "Properties": {
        "VpcId": {
          "Ref": "VpcId"
        },
        "StickySessionConfig": {
          "Cookie": "B490B5EBF6F3CD402E515D22****",
          "CookieTimeout": 1000,
          "StickySessionEnabled": true,
          "StickySessionType": "Insert"
        },
        "HealthCheckConfig": {
          "HealthCheckConnectPort": 80,
          "HealthCheckEnabled": true,
          "HealthCheckHost": "www.example.com",
          "HealthCheckCodes": [
            "http_2xx"
          ],
          "HealthCheckHttpVersion": "HTTP1.0",
          "HealthCheckInterval": 5,
          "HealthCheckMethod": "HEAD",
          "HealthCheckPath": "/test/index.html",
          "HealthCheckProtocol": "HTTP",
          "HealthCheckTimeout": 3,
          "HealthyThreshold": 4,
          "UnhealthyThreshold": 4
        },
        "ServerGroupName": "TestServerGroup"
      }
    }
  },
  "Outputs": {
    "ServerGroupId": {
      "Description": "The ID of the server group.",
      "Value": {
        "Fn::GetAtt": [
          "ServerGroup",
          "ServerGroupId"
        ]
      }
    }
  }
}