You need to enable JavaScript to run this app.
文档中心
负载均衡

负载均衡

复制全文
下载 pdf
服务器组
CreateServerGroup - 创建服务器组
复制全文
下载 pdf
CreateServerGroup - 创建服务器组
调用 CreateServerGroup 接口,创建服务器组。​
使用说明​
  • 每个账号最多创建 50 个服务器组。​
  • 每秒最多提交 10 个 API 请求。​
调试​
API Explorer
您可以通过 API Explorer 在线发起调用,无需关注签名生成过程,快速获取调用结果。
​
请求参数​
下方仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数。​
Action string 必选 示例值:CreateServerGroup​
要执行的操作,取值:CreateServerGroup。​
​
Version string 必选 示例值:2020-04-01​
API的版本,取值:2020-04-01。​
​
HealthCheck.Enabled string 可选 示例值:on​
监听器是否开启健康检查功能。取值如下:​
  • on(默认值):开启。​
  • off:不开启。​
​
ServerGroupName string 可选 示例值:default_servergroup​
后端服务器组的名称。​
  • 必须以字母或中文开头,可包含数字、点号(.)、下划线(_)和短横线(-)。​
  • 长度限制为1 ~ 128个字符。​
  • 不传入该参数或该参数不传入数值时,默认为后端服务器组 ID。​
​
ServerGroupType string 可选 示例值:instance​
后端服务器组的类型。取值如下:​
  • instance(默认值):服务器类型,该类型服务器组支持添加 ecs、eni 实例作为后端服务器。​
  • ip:IP类型,该类型服务器组支持添加 IP 地址作为后端服务器。​
​
Scheduler string 可选 示例值:wrr​
调度算法。取值如下:​
  • wrr(默认值):加权轮询。​
  • wlc:加权最小连接数。​
  • sh:源地址哈希。​
​
HealthCheck.Interval integer 可选 示例值:2​
开启健康检查后,执行健康检查的时间间隔。 单位:秒,取值:1~300s,默认值为 2。​
​
HealthCheck.Timeout integer 可选 示例值:2​
开启健康检查后,健康检查的响应超时时间。​
  • 表示如果后端服务器在指定的时间内没有正确响应,则判定为健康检查异常。​
  • 响应超时时间需小于等于检查时间间隔。​
  • 单位:秒,取值:1~60,默认值为 2。​
​
HealthCheck.UnhealthyThreshold integer 可选 示例值:3​
开启健康检查后,健康检查的不健康阈值。​
  • 表示连续执行指定次数的健康检查,结果均为异常的后端服务器将判定为健康检查异常。​
  • 单位:次,取值:2~10,默认值为 3。​
​
StickySessionConfig.StickySessionEnabled string 可选 示例值:off​
是否开启会话保持。取值如下:​
  • on:开启。​
  • off(默认值):关闭。​
​
StickySessionConfig.StickySessionType string 可选 示例值:insert​
对 Cookie 的处理方式。当 StickySessionConfig.StickySessionEnabled 值为 on 时,此字段参数必填。取值如下:​
  • insert(默认值):植入 Cookie;​
  • ALB 会记录客户端请求第一次转发到的后端服务器。ALB 在返回请求中植入 Cookie ,后续客户端请求携带此 Cookie,ALB 会将请求转发到之前记录的后端服务器上。​
  • server:重写 Cookie;​
  • 开启重写 Cookie 的会话保持后,在客户端请求第一次转发到后端服务器后,ALB 在返回请求中发现您自定义的 Cookie 时,会对原来的 Cookie 进行重写。后续客户端请求携带改写后的 Cookie,ALB 会将请求转发到之前记录的后端服务器上。​
​
StickySessionConfig.Cookie string 可选 示例值:MY_COOKIE​
服务配置的会话保持 Cookie 名称。仅在开启会话保持功能并选择重写 Cookie 时有效。 具体规则如下:​
  • Cookie 名称长度为1~200个字符。​
  • 名称只能包含 ASCII 英文字母和数字字符,不能包含半角逗号(,)、半角分号(;)或空格,也不能以美元符号($)开头。​
  • 当 StickySessionConfig.StickySessionEnabled 值为 on,且 StickySessionConfig.StickySessionType 为 server时,此参数必填。​
  • 当 StickySessionConfig.StickySessionEnabled 值为 on,且 StickySessionConfig.StickySessionType 为 insert 时,该参数无效。​
​
HealthCheck.HttpCode string 可选 示例值:"http_2xx,http_3xx"​
健康检查正常的HTTP状态码。多个状态码间用半角逗号","分隔。只有 HealthCheck.Protocol 设置为 HTTP 时该参数生效。取值如下:​
  • http_2xx(默认值)​
  • http_3xx(默认值)​
  • http_4xx​
  • http_5xx​
​
HealthCheck.URI string 可选 示例值:/health​
健康检查的路径,需配置为后端服务器上真实对外提供的路径。只有 HealthCheck.Protocol 设置为 HTTP 时该参数生效。​
  • 必须以字符‘/’开头。​
  • 仅包含字母、数字、‘-’、‘_’、‘/’、‘.’、‘%’、‘?’、‘#’、‘&’、‘=’ 字符。​
  • 长度限制为1 ~ 128个字符。​
  • 不传入该参数或该参数不传入数值时,默认为“/”。​
​
HealthCheck.Protocol string 可选 示例值:HTTP​
健康检查协议。​
  • HTTP(默认值)​
  • TCP​
​
HealthCheck.Method string 可选 示例值:HEAD​
开启健康检查后,健康检查的方法。只有 HealthCheck.Protocol 设置为 HTTP 时该参数生效。取值如下:​
  • GET:服务器需支持GET方法。​
  • HEAD(默认值):服务器仅返回HEAD头部信息,可以降低后端性能消耗,但服务器需要支持HEAD方法。​
​
StickySessionConfig.CookieTimeout integer 可选 示例值:1000​
会话保持 Cookie 超时时间。仅在开启会话保持功能并选择植入 Cookie 时有效。 单位:秒。具体规则如下:​
  • 超时时间的取值范围:1~86400。 默认值为:1000。​
  • 当 StickySessionConfig.StickySessionEnabled 值为 on,且 StickySessionConfig.StickySessionType 为 insert 时,此参数必填。​
  • 当 StickySessionConfig.StickySessionEnabled 值为 on,且 StickySessionType 为 server 时,此参数无效。​
​
Description string 可选 示例值:This is the default servergroup​
后端服务器组的描述。​
  • 必须以字母或中文开头,可包含数字、英文逗号(,)、点号(.)、下划线(_)、空格( )、等号(=)、短横线(-)、中文逗号(,)、中文句号(。)。​
  • 长度限制为1 ~ 255个字符。​
  • 不传入该参数或该参数不传入数值时,默认为空字符串。​
​
HealthCheck.Domain string 可选 示例值:www.test.com​
健康检查的域名,需配置为后端服务器上真实对外提供服务的地址。只有 HealthCheck.Protocol 设置为 HTTP 时该参数生效。​
  • 需至少包含一个‘.’,且不允许以‘.’开头或结尾。​
  • 域名每一级由字母、数字、‘-’、‘.’字符组成,且‘-’不得出现在每一级的头部或尾部。​
  • 长度限制为1 ~ 128个字符。​
  • 不传入该参数或该参数不传入数值时,默认为空,表示负载均衡使用各后端服务器的私网IP地址进行健康检查。​
​
HealthCheck.HealthyThreshold integer 可选 示例值:3​
开启健康检查后,健康检查的健康阈值。​
  • 表示连续执行指定次数的健康检查,结果均为正常的后端服务器将判定为健康检查正常。​
  • 单位:次,取值:2~10,默认值为 3。​
​
HealthCheck.HttpVersion string 可选 示例值:HTTP1.0​
健康检查HTTP协议版本,只有 HealthCheck.Protocol 设置为 HTTP 时该参数生效。取值如下:​
  • HTTP1.0(使用API时,HTTP协议版本默认值)​
  • HTTP1.1​
​
HealthCheck.Port integer 可选 示例值:80​
健康检查端口。支持取值:​
  • 0(默认值):使用后端服务器端口进行健康检查。​
  • 1-65535:使用您指定的端口进行健康检查。​
​
Protocol string 可选 示例值:HTTP​
后端协议。取值如下:​
  • HTTP(默认值):后端协议为 HTTP 时,后端服务器组可以关联 HTTP 和 HTTPS 监听器。​
  • HTTPS:后端协议为 HTTPS 时,后端服务器组可以关联 HTTP 和 HTTPS 监听器。​
  • gRPC:后端协议为 gRPC 时,后端服务器组可以关联 HTTP/2 监听器。​
说明​
只有标准版 ALB 实例支持后端协议 HTTPS 和 gRPC。如需将Protocol指定为HTTPS 或 gRPC,请提交工单进行申请。​
​
IpAddressType string 可选 示例值:IPv4​
服务器组IP地址类型。取值如下:​
  • IPv4(默认值):IPv4类型。​
​
CrossZoneEnabled string 可选 示例值:on​
是否开启服务器组的跨可用区负载均衡功能。取值如下:​
  • on(默认值):开启。​
  • off:不开启。​
如果您不开启该功能,服务器组只能关联标准版 ALB 实例。​
​
Tags.N.Value string[] 可选 示例值:Tags.1.Value=v1&Tags.2.Value=v2​
标签的标签值。如果传入该参数,则必须先传入Tags.N.Key。具体规则如下:​
  • 长度限制为0~256个字符。​
  • 大小写敏感。​
  • 不能以空格开头或结尾。​
  • 允许包含各国语言文字、数字、空格()、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、减号(-)和@。​
​
Tags.N.Key string[] 可选 示例值:Tags.1.Key=k1&Tags.2.Key=k2​
标签的标签键。具体规则如下:​
  • 长度限制为1~128个字符。​
  • 大小写敏感。​
  • 不能以volc:的任意大小写组合开头。​
  • 不能以空格开头或结尾。​
  • 允许包含各国语言文字、数字、空格()、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、减号(-)和@。​
  • 同一资源的标签键不允许重复。​
​
ProjectName string 可选 示例值:default​
后端服务器组所属项目名称。​
​
VpcId string 可选 示例值:vpc-3th8z3ajkd4bwbhc****​
服务器组所属的 Vpc 的 ID 。​
​
SlowStartConfig.SlowStartEnabled string 可选 示例值:off​
是否开启慢启动功能。取值如下:​
  • on:开启。开启后,新加入的健康后端服务器在设定时间内权重从0逐步上升到设定值,实现平滑预热。约束如下:​
  • 仅当调度算法为wrr(加权轮询)时,支持开启慢启动。​
  • 仅组内已有健康后端服务器时,新加入的健康服务器才会进入慢启动。​
  • off(默认值):不开启。​
说明​
慢启动功能正在邀测中,如需试用,请联系客户经理。​
​
SlowStartConfig.SlowStartDuration integer 可选 示例值:30​
慢启动持续时间。 单位:秒。​
  • 取值范围:30~900。​
  • 默认值为 30。​
​
SpaceNetworkId string 可选 示例值:csn-bpkdt37pq72zv****​
服务器组所属 SpaceNetwork 的 ID。​
仅当 ServerGroupType 为 claw 时参数有效。​
​
​
​
返回参数​
下方仅列出本接口特有的返回参数。更多信息请参见返回结构。​
RequestId string 示例值:20210811152539010225146063030****​
请求ID。​
​
ServerGroupId string 示例值:rsp-bp1o94dp5i6ea****​
后端服务器组ID。​
​
​
​
请求示例​
​
GET /?Action=CreateServerGroup&VpcId=vpc-3th8z3ajkd4bwbhc****&ServerGroupName=test&Scheduler=wrr&HealthCheck.HttpCode="http_2xx,http_3xx"&Version=2020-04-01 HTTP/1.1​
Host: alb.cn-beijing.volcengineapi.com​
X-Date: 20251121T094038Z​
Authorization: HMAC-SHA256 Credential=Adfks******wekfwe/20251121/cn-beijing/alb/request, SignedHeaders=host;x-date, Signature=47a7d934ff7b37c03938******cd7b8278a40a1057690c401e92246a0e41085f​
​
返回示例​
​
{​
"ResponseMetadata": {​
"RequestId": "20210816110638****2514606306AF947C",​
"Action": "CreateServerGroup",​
"Version": "2020-04-01",​
"Service": "alb",​
"Region": "cn-beijing"​
},​
"Result": {​
"RequestId": "202108161106****22514606306AF947C",​
"ServerGroupId": "rsp-2ff0jsqj1hslc5oxruuy09okg"​
}​
}​
​
错误码​
下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。​
​
状态码​
错误码​
错误信息​
说明​
400​
Invalid%s.Malformed​
MismatchThe specified %s is malformed.​
指定的 %s 参数格式不合法。​
400​
MissingParameter​
The request is missing a required parameter. Ensure that you have supplied all the required parameters for the request; for example, '%s'.​
该请求缺少必要参数。请确保发起请求已提供全部必要参数,比如: %s。​
400​
InvalidParameter​
Data unmarshal failed.​
请求解析失败。​
400​
InvalidScheduler.Malformed​
The specified Scheduler is malformed.​
指定的 Scheduler 参数格式不合法。​
400​
InvalidHealthCheck.URI.Malformed​
The specified HealthCheck.URI is malformed.​
指定的 HealthCheck.URI 参数格式不合法。​
400​
InvalidHealthCheck.HttpCode.Malformed​
The specified HealthCheck.HttpCode is malformed.​
指定的 HealthCheck.HttpCode 参数格式不合法。​
400​
InvalidHealthCheck.Domain.Malformed​
The specified HealthCheck.Domain is malformed.​
指定的 HealthCheck.Domain 参数格式不合法。​
400​
QuotaExceed.ServerGroupPerRegion​
You've reached the limit on the number of server groups the current region you can create in, usage xx/xx.​
已达到当前地域可创建服务器组的数量上限。目前已使用xxx,配额为xxx。​
400​
OperationFailed.AddIntoProjectFailed​
The request on the specified resource failed due to adding it into the project failed.​
因将资源加入至项目中失败,对于该资源的操作请求失败。​
400​
InvalidHealthCheck.HttpVersion.Malformed​
The specified HealthCheck.HttpVersion is malformed.​
指定的 HealthCheck.HttpVersion 参数格式不合法。​
400​
InvalidHealthCheck.Interval.Malformed​
The specified HealthCheck.Interval is malformed.​
指定的 HealthCheck.Interval 参数格式不合法。​
400​
InvalidHealthCheck.Timeout.Malformed​
The specified HealthCheck.Timeout is malformed.​
指定的 HealthCheck.Timeout 参数格式不合法。​
400​
InvalidHealthCheck.HealthyThreshold.Malformed​
The specified HealthCheck.HealthyThreshold is malformed.​
指定的 HealthCheck.HealthyThreshold 参数格式不合法。​
400​
InvalidHealthCheck.UnhealthyThreshold.Malformed​
The specified HealthCheck.UnhealthyThreshold is malformed.​
指定的 HealthCheck.UnhealthyThreshold 参数格式不合法。​
400​
InvalidHealthCheck.Enabled.Malformed​
The specified HealthCheck.Enabled is malformed.​
指定的 HealthCheck.Enabled 参数格式不合法。​
400​
InvalidHealthCheck.Protocol.Malformed​
The specified HealthCheck.Protocol is malformed.​
指定的 HealthCheck.Protocol 参数格式不合法。​
400​
MissingParameter​
The request is missing a required parameter. Ensure that you have supplied all the required parameters for the request; for example, 'HealthCheck.Domain'.​
该请求缺少必要参数。请确保发起请求已提供全部必要参数,比如: HealthCheck.Domain。​
400​
InvalidServerGroupType.Malformed​
The specified ServerGroupType is malformed.​
指定的 ServerGroupType 参数格式不合法。​
400​
InvalidDescription.Malformed​
The specified Description is malformed.​
指定的 Description 参数格式不合法。​
400​
InvalidServerGroupName.Malformed​
The specified ServerGroupName is malformed.​
指定的 ServerGroupName 参数格式不合法。​
400​
InvalidStickySessionConfig.StickySessionEnabled.Malformed​
The specified StickySessionConfig.StickySessionEnabled is malformed.​
指定的 StickySessionConfig.StickySessionEnabled 参数格式不合法。​
400​
InvalidStickySessionConfig.StickySessionType.Malformed​
The specified StickySessionConfig.StickySessionType is malformed.​
指定的 StickySessionConfig.StickySessionType 参数格式不合法。​
400​
InvalidStickySessionConfig.Cookie.Malformed​
The specified StickySessionConfig.Cookie is malformed.​
指定的 StickySessionConfig.Cookie 参数格式不合法。​
400​
InvalidStickySessionConfig.CookieTimeout.Malformed​
The specified StickySessionConfig.CookieTimeout is malformed.​
指定的 StickySessionConfig.CookieTimeout 参数格式不合法。​
400​
InvalidHealthCheck.Method.Malformed​
The specified HealthCheck.Method is malformed.​
指定的 HealthCheck.Method 参数格式不合法。​
400​
OperationFailed.QueryProject​
The request on the specified resource failed due to the query on project failed.​
因查询项目失败,对于该资源的操作请求失败。​
400​
OperationFailed.AddTagFailed​
The request on the specified resource failed due to adding tag to the resource failed.​
因给资源添加标签失败,对于该资源的操作请求失败。​
400​
InvalidProtocol.Malformed​
The specified Protocol is malformed.​
指定的 Protocol 参数格式不合法。​
400​
InvalidHealthCheckPort.Malformed​
The specified HealthCheck.Port is malformed.​
指定的HealthCheck.Port参数格式不合法。​
400​
InvalidTags.Key.Malformed​
The specified Tags.Key is malformed.​
指定的 Tags.Key 参数格式不合法。​
400​
InvalidTags.Key.Duplicated​
The specified Tags.Key is duplicated.​
指定的 Tags.Key 重复。​
400​
InvalidTags.Value.Malformed​
The specified Tags.Value is malformed.​
指定的 Tags.Value 参数格式不合法。​
400​
InvalidProtocol.CrossZoneEnabled​
The specified CrossZoneEnabled is malformed.​
指定的 CrossZoneEnabled 参数格式不合法。​
400​
OperationDenied.BackendServerRemoteOnNotSupport​
The request on the specified BackendServer is denied due to enabling Remote is prohibited when cross-zone forwarding disabled.​
因关闭跨 AZ 转发时,不支持开启远端模式,对于该后端服务器的操作请求被拒绝。​
400​
OperationDenied.StickySessionConfigEnabledUnsupported​
The request on the specified ServerGroup is denied due to enabling StickySessionConfig is prohibited when cross-zone forwarding disabled.​
因服务器组关闭跨 AZ 转发时不可开启会话保持,对于该服务器组的操作请求被拒绝。​
400​
OperationFailed.QueryIAM​
The request on the specified resource failed due to the query on IAM failed.​
因请求 IAM 失败,对于该资源的操作请求失败。​
400​
InvalidSlowStartConfig.SlowStartEnabled.Malformed​
The specified SlowStartConfig.SlowStartEnabled is malformed.​
指定的 SlowStartConfig.SlowStartEnabled 参数格式不合法。​
400​
InvalidSlowStartConfig.SlowStartDuration.Malformed​
The specified SlowStartConfig.SlowStartDuration is malformed.​
指定的 SlowStartConfig.SlowStartDuration 参数格式不合法。​
400​
InvalidScheduler.SlowStartEnabledMismatch​
The specified Scheduler and SlowStartEnabled of ServerGroup do not match. Slow start only supports the WRR scheduling algorithm.​
指定的调度算法和慢启动开关不匹配。慢启动仅支持 wrr 调度算法。​
400​
OperationFailed.QueryArkClaw​
The request on the specified resource failed due to the query on ArkClaw failed.​
因请求 ArkClaw 失败,对于该资源的操作请求失败。​
400​
OperationDenied.ServerGroupTypeAndCrossZoneEnabledConflict​
The request on the specified ServerGroup is denied due to The claw-type ServerGroup does not support to turn off CrossZoneEnabled.​
因 Claw 类型服务器组不支持关闭跨 AZ 转发开关,对于该服务器组的操作请求被拒绝。​
400​
OperationDenied.QueryConditionConflict​
The request on the specified ServerGroup is denied due to VpcId and SpaceNetworkId cannot be specified at the same time.​
因 VpcId 和 SpaceNetworkId 不能同时指定,对于该服务器组的操作请求被拒绝。​
403​
Forbidden​
You are not authorized to create ServerGroup with the type of claw.​
您无权限创建 claw 类型的服务器组。​
403​
Forbidden​
You are not authorized to create ServerGroup with the type of ip.​
您无权限创建 IP 类型的服务器组。​
403​
Forbidden​
You are not authorized to configure the ServerGroup with slow start config.​
您无权限为服务器组开启慢启动配置。​
404​
InvalidVpc.NotFound​
The specified VPC does not exist.​
指定的 VPC 不存在。​
404​
InvalidProject.NotFound​
The specified Project does not exist.​
指定的项目不存在。​
404​
InvalidSpaceNetwork.NotFound​
The specified SpaceNetwork does not exist.​
指定的 SpaceNetwork 不存在。​
500​
InternalError​
An internal error has occurred.​
发生内部错误。请稍后重试或联系工程师进一步咨询。​
​
​
最近更新时间:2026.06.30 20:00:39
这个页面对您有帮助吗?
有用
有用
无用
无用