gcloud alpha compute backend-services update-backend Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud alpha compute backend-services update-backend - update an existing backend in a backend service
- SYNOPSIS
gcloud alpha compute backend-services update-backendBACKEND_SERVICE_NAME([--instance-group=INSTANCE_GROUP:--instance-group-region=INSTANCE_GROUP_REGION|--instance-group-zone=INSTANCE_GROUP_ZONE] | [--network-endpoint-group=NETWORK_ENDPOINT_GROUP:--network-endpoint-group-zone=NETWORK_ENDPOINT_GROUP_ZONE])[--balancing-mode=BALANCING_MODE][--capacity-scaler=CAPACITY_SCALER][--description=DESCRIPTION][--failover][--max-utilization=MAX_UTILIZATION][--preference=PREFERENCE][--traffic-duration=TRAFFIC_DURATION][--clear-custom-metrics|--custom-metrics=[CUSTOM_METRICS,…] |--custom-metrics-file=[CUSTOM_METRICS,…]][--global|--region=REGION][--max-connections=MAX_CONNECTIONS|--max-connections-per-endpoint=MAX_CONNECTIONS_PER_ENDPOINT|--max-connections-per-instance=MAX_CONNECTIONS_PER_INSTANCE|--max-in-flight-requests=MAX_IN_FLIGHT_REQUESTS|--max-in-flight-requests-per-endpoint=MAX_IN_FLIGHT_REQUESTS_PER_ENDPOINT|--max-in-flight-requests-per-instance=MAX_IN_FLIGHT_REQUESTS_PER_INSTANCE|--max-rate=MAX_RATE|--max-rate-per-endpoint=MAX_RATE_PER_ENDPOINT|--max-rate-per-instance=MAX_RATE_PER_INSTANCE][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
(ALPHA)gcloud alpha compute backend-servicesupdate-backendupdates a backend that is part of a backend service. Thisis useful for changing the way a backend behaves. Example changes that can bemade include changing the load balancing policy and draining a backend bysetting its capacity scaler to zero.Backends are instance groups or network endpoint groups. One of the
--network-endpoint-groupor--instance-groupflags isrequired to identify the backend that you are modifying. You cannot change theinstance group or network endpoint group associated with a backend, but you canremove a backend and add a new one withbackend-servicesremove-backendandbackend-services add-backend.The
gcloudcompute backend-services editcommand can also update a backend ifthe use of a text editor is desired.For more information about the available settings, seehttps://cloud.google.com/load-balancing/docs/backend-service.
- POSITIONAL ARGUMENTS
BACKEND_SERVICE_NAME- Name of the backend service to operate on.
- REQUIRED FLAGS
- Exactly one of these must be specified:
- Instance Group
--instance-group=INSTANCE_GROUP- Name of the instance group to update in the backend service. For details onvalid instance names, refer to the criteria documented under the field 'name'at:https://cloud.google.com/compute/docs/reference/rest/v1/instances
This flag argument must be specified if any of the other arguments in this groupare specified.
- At most one of these can be specified:
--instance-group-region=INSTANCE_GROUP_REGION- Region of the instance group to update in the backend service. If not specified,you might be prompted to select a region (interactive mode only).
To avoid prompting when this flag is omitted, you can set the
property:compute/regiongcloudconfigsetcompute/regionREGIONA list of regions can be fetched by running:
gcloudcomputeregionslistTo unset the property, run:
gcloudconfigunsetcompute/regionAlternatively, the region can be stored in the environment variable
.CLOUDSDK_COMPUTE_REGION --instance-group-zone=INSTANCE_GROUP_ZONE- Zone of the instance group to update in the backend service. If not specifiedand the
property isn't set,you might be prompted to select a zone (interactive mode only).compute/zoneTo avoid prompting when this flag is omitted, you can set the
property:compute/zonegcloudconfigsetcompute/zoneZONEA list of zones can be fetched by running:
gcloudcomputezoneslistTo unset the property, run:
gcloudconfigunsetcompute/zoneAlternatively, the zone can be stored in the environment variable
.CLOUDSDK_COMPUTE_ZONE
- Network Endpoint Group
--network-endpoint-group=NETWORK_ENDPOINT_GROUP- Name of the network endpoint group to update in the backend service.
This flag argument must be specified if any of the other arguments in this groupare specified.
--network-endpoint-group-zone=NETWORK_ENDPOINT_GROUP_ZONE- Zone of the network endpoint group to update in the backend service. If notspecified and the
propertyisn't set, you might be prompted to select a zone (interactive mode only).compute/zoneTo avoid prompting when this flag is omitted, you can set the
property:compute/zonegcloudconfigsetcompute/zoneZONEA list of zones can be fetched by running:
gcloudcomputezoneslistTo unset the property, run:
gcloudconfigunsetcompute/zoneAlternatively, the zone can be stored in the environment variable
.CLOUDSDK_COMPUTE_ZONE
- Instance Group
- Exactly one of these must be specified:
- OPTIONAL FLAGS
--balancing-mode=BALANCING_MODE- Defines how to measure whether a backend can handle additional traffic or isfully loaded. For more information, seehttps://cloud.google.com/load-balancing/docs/backend-service#balancing-mode.
BALANCING_MODEmust be one of:CONNECTION- Available if the backend service's load balancing scheme is either
INTERNALorEXTERNAL. Available if the backendservice's protocol is one ofSSL,TCP, orUDP.Spreads load based on how many concurrent connections the backend can handle.
For backend services with --load-balancing-scheme
EXTERNAL, youmust specify exactly one of these additional parameters:--max-connections,--max-connections-per-instance, or--max-connections-per-endpoint.For backend services where
--load-balancing-schemeisINTERNAL, you must omit all of these parameters. CUSTOM_METRICS- Spreads load based on custom defined and reported metrics.
IN_FLIGHTAvailableifthebackendservice's load balancing scheme is
INTERNAL_MANAGED,INTERNAL_SELF_MANAGED, orEXTERNAL_MANAGED. Available if the backend service'sprotocolisoneofHTTP,HTTPS,orHTTP/2.Spreads load based on how many in-flight requests the backend can handle.
You must specify exactly one of these additional parameters:
--max-in-flight-requests,--max-in-flight-requests-per-instance, or--max-in-flight-requests-per-endpoint, and--traffic-duration=LONG.RATE- Available if the backend service's load balancing scheme is
INTERNAL_MANAGED,INTERNAL_SELF_MANAGED, orEXTERNAL. Available if the backend service's protocol is one ofHTTP, HTTPS, or HTTP/2.Spreads load based on how many HTTP requests per second (RPS) the backend canhandle.
You must specify exactly one of these additional parameters:
--max-rate,--max-rate-per-instance, or--max-rate-per-endpoint. UTILIZATION- Available if the backend service's load balancing scheme is
INTERNAL_MANAGED,INTERNAL_SELF_MANAGED, orEXTERNAL. Available only for managed or unmanaged instance groupbackends.Spreads load based on the backend utilization of instances in a backend instancegroup.
The following additional parameters may be specified:
--max-utilization,--max-rate,--max-rate-per-instance,--max-connections,--max-connections-per-instance. For valid combinations, see--max-utilization.
--capacity-scaler=CAPACITY_SCALER- Scales down the target capacity (max utilization, max rate, or max connections)without changing the target capacity. For usage guidelines and examples, seeCapacityscaler.
--description=DESCRIPTION- An optional, textual description for the backend.
--failover- Designates whether this is a failover backend. More than one failover backendcan be configured for a given BackendService. Not compatible with the --globalflag
--max-utilization=MAX_UTILIZATION- Defines the maximum target for average utilization of the backend instancegroup. Supported values are
0.0(0%) through1.0(100%). This is an optional parameter for theUTILIZATIONbalancingmode.You can use this parameter with other parameters for defining target capacity.For usage guidelines, seeBalancingmode combinations.
--preference=PREFERENCE- This parameter specifies whether a backend should be fully utilized beforesending traffic to backends with the default preference. This parameter cannotbe used with regional managed instance groups and when the endpoint type of anattached network endpoint group is INTERNET_IP_PORT, INTERNET_FQDN_PORT, orSERVERLESS.
PREFERENCEmust be one of:DEFAULT- This is the default setting. If the designated preferred backends don't haveenough capacity, backends in the default category are used. Traffic isdistributed between default backends based on the load balancing algorithm used.
PREFERRED- Backends with this preference setting are used up to their capacity limitsfirst, while optimizing overall network latency.
--traffic-duration=TRAFFIC_DURATION- The expected traffic duration for this service.
TRAFFIC_DURATIONmust be one of:LONG- Most of the requests are expected to take more than multiple seconds to finish.
SHORT- Most requests are expected to finish with a sub-second latency.
TRAFFIC_DURATION_UNSPECIFIED- Default value. Defaults to SHORT.
- At most one of these can be specified:
--clear-custom-metrics- Clears current list of CUSTOM_METRICS.
--custom-metrics=[CUSTOM_METRICS,…]- List of custom metrics that are used for CUSTOM_METRICS balancing mode andWEIGHTED_ROUND_ROBIN locality load balancing policy.
Example:
gcloudalphacomputebackend-servicesupdate-backend--custom-metrics='name=my-signal,maxUtilization=0.8,dryRun=true'gcloudalphacomputebackend-servicesupdate-backend--custom-metrics='name=my-signal,maxUtilization=0.8,dryRun=true'--custom-metrics='name=my-signal2,maxUtilization=0.2'gcloudalphacomputebackend-servicesupdate-backend--custom-metrics='[{"name" : "my-signal", "maxUtilization" :0.8, "dryRun" : true}, {"name" : "my-signal2", "maxUtilization" : 0.1}]'Sets
custom_metricsvalue.dryRun- Sets
dryRunvalue. maxUtilization- Sets
maxUtilizationvalue. name- Required, sets
namevalue.
Shorthand Example:--custom-metrics=dryRun=boolean,maxUtilization=float,name=string--custom-metrics=dryRun=boolean,maxUtilization=float,name=string
JSON Example:--custom-metrics='[{"dryRun": boolean, "maxUtilization": float, "name": "string"}]'
File Example:--custom-metrics=path_to_file.(yaml|json)
--custom-metrics-file=[CUSTOM_METRICS,…]- File path to json file with custom metrics that are used for CUSTOM_METRICSbalancing mode and WEIGHTED_ROUND_ROBIN locality load balancing policy.
Example:
gcloudalphacomputebackend-servicesupdate-backend--custom-metrics-file='customMetric.json'Sets
custom_metrics_filevalue.dryRun- Sets
dryRunvalue. maxUtilization- Sets
maxUtilizationvalue. name- Required, sets
namevalue.
Shorthand Example:--custom-metrics-file=dryRun=boolean,maxUtilization=float,name=string--custom-metrics-file=dryRun=boolean,maxUtilization=float,name=string
JSON Example:--custom-metrics-file='[{"dryRun": boolean, "maxUtilization": float, "name": "string"}]'
File Example:--custom-metrics-file=path_to_file.(yaml|json)
- At most one of these can be specified:
--global- If set, the backend service is global.
--region=REGION- Region of the backend service to operate on. Overrides the default
compute/regionproperty value for this command invocation.
- At most one of these can be specified:
--max-connections=MAX_CONNECTIONS- Maximum concurrent connections that the backend can handle. Valid for networkendpoint group and instance group backends (except for regional managed instancegroups).
--max-connections-per-endpoint=MAX_CONNECTIONS_PER_ENDPOINT- Only valid for network endpoint group backends. Defines a maximum number ofconnections per endpoint if all endpoints are healthy. When one or moreendpoints are unhealthy, an effective maximum average number of connections perhealthy endpoint is calculated by multiplying
MAX_CONNECTIONS_PER_ENDPOINTby the number of endpoints in thenetwork endpoint group, and then dividing by the number of healthy endpoints. --max-connections-per-instance=MAX_CONNECTIONS_PER_INSTANCE- Only valid for instance group backends. Defines a maximum number of concurrentconnections per instance if all instances in the instance group are healthy.When one or more instances are unhealthy, an effective average maximum number ofconnections per healthy instance is calculated by multiplying
MAX_CONNECTIONS_PER_INSTANCEby the number of instances in theinstance group, and then dividing by the number of healthy instances. --max-in-flight-requests=MAX_IN_FLIGHT_REQUESTS- Maximum number of in-flight requests that the backend can handle.
--max-in-flight-requests-per-endpoint=MAX_IN_FLIGHT_REQUESTS_PER_ENDPOINT- Only valid for network endpoint group backends. Defines the maximum number ofin-flight requests per endpoint.
--max-in-flight-requests-per-instance=MAX_IN_FLIGHT_REQUESTS_PER_INSTANCE- Only valid for instance group backends. Defines the maximum number of in-flightrequests per instance.
--max-rate=MAX_RATE- Maximum number of HTTP requests per second (RPS) that the backend can handle.Valid for network endpoint group and instance group backends (except forregional managed instance groups). Must not be defined if the backend is amanaged instance group using load balancing-based autoscaling.
--max-rate-per-endpoint=MAX_RATE_PER_ENDPOINT- Only valid for network endpoint group backends. Defines a maximum number of HTTPrequests per second (RPS) per endpoint if all endpoints are healthy. When one ormore endpoints are unhealthy, an effective maximum rate per healthy endpoint iscalculated by multiplying
MAX_RATE_PER_ENDPOINTby the number ofendpoints in the network endpoint group, and then dividing by the number ofhealthy endpoints. --max-rate-per-instance=MAX_RATE_PER_INSTANCE- Only valid for instance group backends. Defines a maximum number of HTTPrequests per second (RPS) per instance if all instances in the instance groupare healthy. When one or more instances are unhealthy, an effective maximum RPSper healthy instance is calculated by multiplying
MAX_RATE_PER_INSTANCEby the number of instances in the instancegroup, and then dividing by the number of healthy instances. This parameter iscompatible with managed instance group backends that use autoscaling based onload balancing.
- GCLOUD WIDE FLAGS
- These flags are available to all commands:
--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.Run
$gcloud helpfor details. - NOTES
- This command is currently in alpha and might change without notice. If thiscommand fails with API permission errors despite specifying the correct project,you might be trying to access an API with an invitation-only early accessallowlist. These variants are also available:
gcloudcomputebackend-servicesupdate-backendgcloudbetacomputebackend-servicesupdate-backend
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-30 UTC.