All Products
Search
Document Center

Server Load Balancer:UpdateServerGroupAttribute

Last Updated:Dec 18, 2024

Modifies the configurations of a server group, such as health checks, session persistence, server group names, routing algorithms, and protocols.

Operation description

Description

UpdateServerGroupAttribute 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 the ListServerGroups operation to query the status of a server group:

  • If a server group is in the Configuring state, the configuration of the server group is being modified.
  • If a server group is in the Available state, the configuration of the server group is modified.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
alb:UpdateServerGroupAttributeupdate
*ServerGroup
acs:alb:{#regionId}:{#accountId}:servergroup/{#servergroupId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ServerGroupNamestringNo

The server group name.

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
SchedulerstringNo

The scheduling algorithm. Valid values:

  • Wrr: the weighted round robin algorithm. Backend servers that have higher weights receive more requests than those that have lower weights.
  • Wlc: the weighted least connections algorithm. 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. Requests from the same source IP address are distributed to the same backend server.
Wrr
ClientTokenstringNo

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.
5A2CFF0E-5718-45B5-9D4D-70B3FF3898
DryRunbooleanNo

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

  • true: checks the request without performing the operation. 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.
true
HealthCheckConfigobjectNo

The configuration of health checks.

HealthCheckConnectPortintegerNo

The backend port that is used for health checks.

Valid values: 0 to 65535.

If you set the value to 0, the backend port is used for health checks.

Note This parameter takes effect only if you set HealthCheckEnabled to true.
80
HealthCheckEnabledbooleanNo

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

  • true
  • false
true
HealthCheckHoststringNo

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.
example.com
HealthCheckCodesarrayNo

The HTTP status codes that indicate healthy backend servers.

stringNo

The HTTP status codes that indicate 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 (,).
  • When 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 you set HealthCheckEnabled to true and HealthCheckProtocol to HTTP, HTTPS, or gRPC.
200
HealthCheckHttpVersionstringNo

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

  • HTTP1.0
  • HTTP1.1
Note This parameter takes effect only if you set HealthCheckEnabled to true and HealthCheckProtocol to HTTP or HTTPS.
HTTP1.1
HealthCheckIntervalintegerNo

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

Valid values: 1 to 50.

Note This parameter takes effect only if you set HealthCheckEnabled to true.
5
HealthCheckMethodstringNo

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: gRPC health checks use the POST method by default.
  • HEAD: HTTP and HTTPS health checks use the HEAD method by default.
Note This parameter takes effect only if you set HealthCheckEnabled to true and HealthCheckProtocol to HTTP, HTTPS, or gRPC.
HEAD
HealthCheckPathstringNo

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 you set HealthCheckEnabled to true and HealthCheckProtocol to HTTP or HTTPS.
/test/index.html
HealthCheckProtocolstringNo

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 supports encryption and provides higher security than HTTP.
  • 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
HealthCheckTimeoutintegerNo

The timeout period of a health check response. If a backend ECS instance does not respond within the specified timeout period, the ECS instance fails the health check. Unit: seconds.

Valid values: 1 to 300.

Note This parameter takes effect only if you set HealthCheckEnabled to true.
3
HealthyThresholdintegerNo

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

Valid values: 2 to 10.

4
UnhealthyThresholdintegerNo

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

Valid values: 2 to 10.

4
StickySessionConfigobjectNo

The configuration of session persistence.

CookiestringNo

The cookie to be configured on the server.

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

Note This parameter takes effect when the StickySessionEnabled parameter is set to true and the StickySessionType parameter is set to Server.
B490B5EBF6F3CD402E515D22BCDA1598
CookieTimeoutintegerNo

The timeout period of a cookie. Unit: seconds.

Valid values: 1 to 86400.

Note This parameter takes effect when the StickySessionEnabled parameter is set to true and the StickySessionType parameter is set to Insert.
1000
StickySessionEnabledbooleanNo

Specifies whether to enable session persistence. Valid values:

  • true
  • false (default)
false
StickySessionTypestringNo

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

  • Insert: inserts a cookie.

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 forwards 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. Subsequent requests to ALB carry this user-defined cookie, and ALB determines the destination servers of the requests based on the cookies.

Note This parameter takes effect when the StickySessionEnabled parameter is set to true for the server group.
Insert
ServerGroupIdstringYes

The server group ID.

sgp-atstuj3rtop****
UpstreamKeepaliveEnabledbooleanNo

Specifies whether to enable persistent TCP connections.

ServiceNamestringNo

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.

test2
UchConfigobjectNo

The configurations of consistent hashing based on URLs.

TypestringYes

The type of the parameter. Only query strings are supported.

QueryString
ValuestringYes

The value of the parameter used for consistent hashing.

abc
ConnectionDrainConfigobjectNo

The configurations of connection draining.

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

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

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

ConnectionDrainEnabledbooleanNo

Specifies whether to enable connection draining. Valid values:

  • true
  • false
false
ConnectionDrainTimeoutintegerNo

The timeout period of connection draining.

Valid values: 0 to 900.

300
SlowStartConfigobjectNo

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.

Note
  • Basic ALB instances do not support slow starts. Standard and WAF-enabled ALB instances support slow starts.
  • Server groups of the instance 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.
  • SlowStartEnabledbooleanNo

    Indicates whether slow starts are enabled. Valid values:

    • true
    • false
    false
    SlowStartDurationintegerNo

    The duration of a slow start.

    30
    CrossZoneEnabledbooleanNo

    Indicates whether cross-zone load balancing is enabled for the server group. 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 parameters

    ParameterTypeDescriptionExample
    object

    The response parameters.

    JobIdstring

    The ID of the asynchronous job.

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

    The request ID.

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

    Examples

    Sample success responses

    JSONformat

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

    Error codes

    HTTP status codeError codeError messageDescription
    400IncorrectStatus.ServerGroupThe status of %s [%s] is incorrect.The status of %s [%s] is incorrect.
    400Mismatch.LoadBalancerEditionAndConnectionDrainThe %s and %s are mismatched.The %s and %s are mismatched.
    400Mismatch.ServerGroupSchedulerAndSlowStartEnableThe %s and %s are mismatched.The %s and %s are mismatched.
    400QuotaExceeded.ConnectionDrainTimeoutThe quota of %s is exceeded, usage %s/%s.The quota of %s is exceeded, usage %s/%s.
    400UnsupportedFeature.ConnectionDrainThe feature of %s is not supported.The feature of %s is not supported.
    400QuotaExceeded.SlowStartDurationThe quota of %s is exceeded, usage %s/%s.The quota of %s is exceeded, usage %s/%s.
    400UnsupportedFeature.SlowStartThe feature of %s is not supported.-
    400Mismatch.LoadBalancerEditionAndSlowStartEnableThe %s and %s are mismatched.The %s and %s are mismatched.
    400OperationDenied.UpstreamKeepaliveDisabledThe operation is not allowed because of UpstreamKeepaliveDisabled.Updating not allowed Backend long connection is closed
    400OperationDenied.UpstreamKeepaliveEnabledThe operation is not allowed because of UpstreamKeepaliveEnabled.Update not allowed to open Backend Long connection is in the open state
    400CloseUpstreamKeepaliveNotSupportThe param of UpstreamKeepalive is not Support.close keepalive attribute for server group is not supported
    404ResourceNotFound.ServerGroupThe specified resource %s is not found.-

    For a list of error codes, visit the Service error codes.

    Change history

    Change timeSummary of changesOperation
    2024-11-28The Error code has changed. The request parameters of the API has changedView Change Details
    2024-02-23The Error code has changed. The request parameters of the API has changedView Change Details
    2023-11-03The Error code has changed. The request parameters of the API has changedView Change Details
    2023-04-11The Error code has changed. The request parameters of the API has changedView Change Details