Class BackendService (1.15.0)

BackendService(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Represents a Backend Service resource. A backend service defines how Google Cloud load balancers distribute traffic. The backend service configuration contains a set of values, such as the protocol used to connect to backends, various distribution and session settings, health checks, and timeouts. These settings provide fine-grained control over how your load balancer behaves. Most of the settings have default values that allow for easy configuration if you need to get started quickly. Backend services in Google Compute Engine can be either regionally or globally scoped. * Global <https://cloud.google.com/compute/docs/reference/rest/v1/backendServices> * Regional <https://cloud.google.com/compute/docs/reference/rest/v1/regionBackendServices> For more information, see Backend Services.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Attributes

NameDescription
affinity_cookie_ttl_sec int
Lifetime of cookies in seconds. This setting is applicable to external and internal HTTP(S) load balancers and Traffic Director and requires GENERATED_COOKIE or HTTP_COOKIE session affinity. If set to 0, the cookie is non-persistent and lasts only until the end of the browser session (or equivalent). The maximum allowed value is two weeks (1,209,600). Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. This field is a member of oneof_ _affinity_cookie_ttl_sec.
backends MutableSequence[google.cloud.compute_v1.types.Backend]
The list of backends that serve this BackendService.
cdn_policy google.cloud.compute_v1.types.BackendServiceCdnPolicy
Cloud CDN configuration for this BackendService. Only available for specified load balancer types. This field is a member of oneof_ _cdn_policy.
circuit_breakers google.cloud.compute_v1.types.CircuitBreakers
This field is a member of oneof_ _circuit_breakers.
compression_mode str
Compress text responses using Brotli or gzip compression, based on the client's Accept-Encoding header. Check the CompressionMode enum for the list of possible values. This field is a member of oneof_ _compression_mode.
connection_draining google.cloud.compute_v1.types.ConnectionDraining
This field is a member of oneof_ _connection_draining.
connection_tracking_policy google.cloud.compute_v1.types.BackendServiceConnectionTrackingPolicy
Connection Tracking configuration for this BackendService. Connection tracking policy settings are only available for Network Load Balancing and Internal TCP/UDP Load Balancing. This field is a member of oneof_ _connection_tracking_policy.
consistent_hash google.cloud.compute_v1.types.ConsistentHashLoadBalancerSettings
Consistent Hash-based load balancing can be used to provide soft session affinity based on HTTP headers, cookies or other properties. This load balancing policy is applicable only for HTTP connections. The affinity to a particular destination host will be lost when one or more hosts are added/removed from the destination service. This field specifies parameters that control consistent hashing. This field is only applicable when localityLbPolicy is set to MAGLEV or RING_HASH. This field is applicable to either: - A regional backend service with the service_protocol set to HTTP, HTTPS, or HTTP2, and load_balancing_scheme set to INTERNAL_MANAGED. - A global backend service with the load_balancing_scheme set to INTERNAL_SELF_MANAGED. This field is a member of oneof_ _consistent_hash.
creation_timestamp str
[Output Only] Creation timestamp in RFC3339 text format. This field is a member of oneof_ _creation_timestamp.
custom_request_headers MutableSequence[str]
Headers that the load balancer adds to proxied requests. See `Creating custom headers
custom_response_headers MutableSequence[str]
Headers that the load balancer adds to proxied responses. See `Creating custom headers
description str
An optional description of this resource. Provide this property when you create the resource. This field is a member of oneof_ _description.
edge_security_policy str
[Output Only] The resource URL for the edge security policy associated with this backend service. This field is a member of oneof_ _edge_security_policy.
enable_c_d_n bool
If true, enables Cloud CDN for the backend service of an external HTTP(S) load balancer. This field is a member of oneof_ _enable_c_d_n.
failover_policy google.cloud.compute_v1.types.BackendServiceFailoverPolicy
Requires at least one backend instance group to be defined as a backup (failover) backend. For load balancers that have configurable failover: `Internal TCP/UDP Load Balancing
fingerprint str
Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a BackendService. An up-to-date fingerprint must be provided in order to update the BackendService, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a BackendService. This field is a member of oneof_ _fingerprint.
health_checks MutableSequence[str]
The list of URLs to the healthChecks, httpHealthChecks (legacy), or httpsHealthChecks (legacy) resource for health checking this backend service. Not all backend services support legacy health checks. See Load balancer guide. Currently, at most one health check can be specified for each backend service. Backend services with instance group or zonal NEG backends must have a health check. Backend services with internet or serverless NEG backends must not have a health check.
iap google.cloud.compute_v1.types.BackendServiceIAP
The configurations for Identity-Aware Proxy on this resource. Not available for Internal TCP/UDP Load Balancing and Network Load Balancing. This field is a member of oneof_ _iap.
id int
[Output Only] The unique identifier for the resource. This identifier is defined by the server. This field is a member of oneof_ _id.
kind str
[Output Only] Type of resource. Always compute#backendService for backend services. This field is a member of oneof_ _kind.
load_balancing_scheme str
Specifies the load balancer type. A backend service created for one type of load balancer cannot be used with another. For more information, refer to Choosing a load balancer. Check the LoadBalancingScheme enum for the list of possible values. This field is a member of oneof_ _load_balancing_scheme.
locality_lb_policies MutableSequence[google.cloud.compute_v1.types.BackendServiceLocalityLoadBalancingPolicyConfig]
A list of locality load-balancing policies to be used in order of preference. When you use localityLbPolicies, you must set at least one value for either the localityLbPolicies[].policy or the localityLbPolicies[].customPolicy field. localityLbPolicies overrides any value set in the localityLbPolicy field. For an example of how to use this field, see Define a list of preferred policies. Caution: This field and its children are intended for use in a service mesh that includes gRPC clients only. Envoy proxies can't use backend services that have this configuration.
locality_lb_policy str
The load balancing algorithm used within the scope of the locality. The possible values are: - ROUND_ROBIN: This is a simple policy in which each healthy backend is selected in round robin order. This is the default. - LEAST_REQUEST: An O(1) algorithm which selects two random healthy hosts and picks the host which has fewer active requests. - RING_HASH: The ring/modulo hash load balancer implements consistent hashing to backends. The algorithm has the property that the addition/removal of a host from a set of N hosts only affects 1/N of the requests. - RANDOM: The load balancer selects a random healthy host. - ORIGINAL_DESTINATION: Backend host is selected based on the client connection metadata, i.e., connections are opened to the same address as the destination address of the incoming connection before the connection was redirected to the load balancer. - MAGLEV: used as a drop in replacement for the ring hash load balancer. Maglev is not as stable as ring hash but has faster table lookup build times and host selection times. For more information about Maglev, see https://ai.google/research/pubs/pub44824 This field is applicable to either: - A regional backend service with the service_protocol set to HTTP, HTTPS, or HTTP2, and load_balancing_scheme set to INTERNAL_MANAGED. - A global backend service with the load_balancing_scheme set to INTERNAL_SELF_MANAGED, INTERNAL_MANAGED, or EXTERNAL_MANAGED. If sessionAffinity is not NONE, and this field is not set to MAGLEV or RING_HASH, session affinity settings will not take effect. Only ROUND_ROBIN and RING_HASH are supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. Check the LocalityLbPolicy enum for the list of possible values. This field is a member of oneof_ _locality_lb_policy.
log_config google.cloud.compute_v1.types.BackendServiceLogConfig
This field denotes the logging options for the load balancer traffic served by this backend service. If logging is enabled, logs will be exported to Stackdriver. This field is a member of oneof_ _log_config.
max_stream_duration google.cloud.compute_v1.types.Duration
Specifies the default maximum duration (timeout) for streams to this service. Duration is computed from the beginning of the stream until the response has been completely processed, including all retries. A stream that does not complete in this duration is closed. If not specified, there will be no timeout limit, i.e. the maximum duration is infinite. This value can be overridden in the PathMatcher configuration of the UrlMap that references this backend service. This field is only allowed when the loadBalancingScheme of the backend service is INTERNAL_SELF_MANAGED. This field is a member of oneof_ _max_stream_duration.
metadatas MutableMapping[str, str]
Deployment metadata associated with the resource to be set by a GKE hub controller and read by the backend RCTH
name str
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. This field is a member of oneof_ _name.
network str
The URL of the network to which this backend service belongs. This field can only be specified when the load balancing scheme is set to INTERNAL. This field is a member of oneof_ _network.
outlier_detection google.cloud.compute_v1.types.OutlierDetection
Settings controlling the ejection of unhealthy backend endpoints from the load balancing pool of each individual proxy instance that processes the traffic for the given backend service. If not set, this feature is considered disabled. Results of the outlier detection algorithm (ejection of endpoints from the load balancing pool and returning them back to the pool) are executed independently by each proxy instance of the load balancer. In most cases, more than one proxy instance handles the traffic received by a backend service. Thus, it is possible that an unhealthy endpoint is detected and ejected by only some of the proxies, and while this happens, other proxies may continue to send requests to the same unhealthy endpoint until they detect and eject the unhealthy endpoint. Applicable backend endpoints can be: - VM instances in an Instance Group - Endpoints in a Zonal NEG (GCE_VM_IP, GCE_VM_IP_PORT) - Endpoints in a Hybrid Connectivity NEG (NON_GCP_PRIVATE_IP_PORT) - Serverless NEGs, that resolve to Cloud Run, App Engine, or Cloud Functions Services - Private Service Connect NEGs, that resolve to Google-managed regional API endpoints or managed services published using Private Service Connect Applicable backend service types can be: - A global backend service with the loadBalancingScheme set to INTERNAL_SELF_MANAGED or EXTERNAL_MANAGED. - A regional backend service with the serviceProtocol set to HTTP, HTTPS, or HTTP2, and loadBalancingScheme set to INTERNAL_MANAGED or EXTERNAL_MANAGED. Not supported for Serverless NEGs. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. This field is a member of oneof_ _outlier_detection.
port int
Deprecated in favor of portName. The TCP port to connect on the backend. The default value is 80. For Internal TCP/UDP Load Balancing and Network Load Balancing, omit port. This field is a member of oneof_ _port.
port_name str
A named port on a backend instance group representing the port for communication to the backend VMs in that group. The named port must be `defined on each backend instance group
protocol str
The protocol this BackendService uses to communicate with backends. Possible values are HTTP, HTTPS, HTTP2, TCP, SSL, UDP or GRPC. depending on the chosen load balancer or Traffic Director configuration. Refer to the documentation for the load balancers or for Traffic Director for more information. Must be set to GRPC when the backend service is referenced by a URL map that is bound to target gRPC proxy. Check the Protocol enum for the list of possible values. This field is a member of oneof_ _protocol.
region str
[Output Only] URL of the region where the regional backend service resides. This field is not applicable to global backend services. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. This field is a member of oneof_ _region.
security_policy str
[Output Only] The resource URL for the security policy associated with this backend service. This field is a member of oneof_ _security_policy.
security_settings google.cloud.compute_v1.types.SecuritySettings
This field specifies the security settings that apply to this backend service. This field is applicable to a global backend service with the load_balancing_scheme set to INTERNAL_SELF_MANAGED. This field is a member of oneof_ _security_settings.
self_link str
[Output Only] Server-defined URL for the resource. This field is a member of oneof_ _self_link.
service_bindings MutableSequence[str]
URLs of networkservices.ServiceBinding resources. Can only be set if load balancing scheme is INTERNAL_SELF_MANAGED. If set, lists of backends and health checks must be both empty.
session_affinity str
Type of session affinity to use. The default is NONE. Only NONE and HEADER_FIELD are supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. For more details, see: `Session Affinity
subsetting google.cloud.compute_v1.types.Subsetting
This field is a member of oneof_ _subsetting.
timeout_sec int
The backend service timeout has a different meaning depending on the type of load balancer. For more information see, Backend service settings. The default is 30 seconds. The full range of timeout values allowed goes from 1 through 2,147,483,647 seconds. This value can be overridden in the PathMatcher configuration of the UrlMap that references this backend service. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. Instead, use maxStreamDuration. This field is a member of oneof_ _timeout_sec.

Classes

CompressionMode

CompressionMode(value)

Compress text responses using Brotli or gzip compression, based on the client's Accept-Encoding header.

Values: UNDEFINED_COMPRESSION_MODE (0): A value indicating that the enum field is not set. AUTOMATIC (165298699): Automatically uses the best compression based on the Accept-Encoding header sent by the client. DISABLED (516696700): Disables compression. Existing compressed responses cached by Cloud CDN will not be served to clients.

LoadBalancingScheme

LoadBalancingScheme(value)

Specifies the load balancer type. A backend service created for one type of load balancer cannot be used with another. For more information, refer to Choosing a load balancer.

Values: UNDEFINED_LOAD_BALANCING_SCHEME (0): A value indicating that the enum field is not set. EXTERNAL (35607499): Signifies that this will be used for external HTTP(S), SSL Proxy, TCP Proxy, or Network Load Balancing EXTERNAL_MANAGED (512006923): Signifies that this will be used for External Managed HTTP(S) Load Balancing. INTERNAL (279295677): Signifies that this will be used for Internal TCP/UDP Load Balancing. INTERNAL_MANAGED (37350397): Signifies that this will be used for Internal HTTP(S) Load Balancing. INTERNAL_SELF_MANAGED (236211150): Signifies that this will be used by Traffic Director. INVALID_LOAD_BALANCING_SCHEME (275352060): No description available.

LocalityLbPolicy

LocalityLbPolicy(value)

The load balancing algorithm used within the scope of the locality. The possible values are: - ROUND_ROBIN: This is a simple policy in which each healthy backend is selected in round robin order. This is the default. - LEAST_REQUEST: An O(1) algorithm which selects two random healthy hosts and picks the host which has fewer active requests. - RING_HASH: The ring/modulo hash load balancer implements consistent hashing to backends. The algorithm has the property that the addition/removal of a host from a set of N hosts only affects 1/N of the requests. - RANDOM: The load balancer selects a random healthy host. - ORIGINAL_DESTINATION: Backend host is selected based on the client connection metadata, i.e., connections are opened to the same address as the destination address of the incoming connection before the connection was redirected to the load balancer. - MAGLEV: used as a drop in replacement for the ring hash load balancer. Maglev is not as stable as ring hash but has faster table lookup build times and host selection times. For more information about Maglev, see https://ai.google/research/pubs/pub44824 This field is applicable to either: - A regional backend service with the service_protocol set to HTTP, HTTPS, or HTTP2, and load_balancing_scheme set to INTERNAL_MANAGED. - A global backend service with the load_balancing_scheme set to INTERNAL_SELF_MANAGED, INTERNAL_MANAGED, or EXTERNAL_MANAGED. If sessionAffinity is not NONE, and this field is not set to MAGLEV or RING_HASH, session affinity settings will not take effect. Only ROUND_ROBIN and RING_HASH are supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true.

Values: UNDEFINED_LOCALITY_LB_POLICY (0): A value indicating that the enum field is not set. INVALID_LB_POLICY (323318707): No description available. LEAST_REQUEST (46604921): An O(1) algorithm which selects two random healthy hosts and picks the host which has fewer active requests. MAGLEV (119180266): This algorithm implements consistent hashing to backends. Maglev can be used as a drop in replacement for the ring hash load balancer. Maglev is not as stable as ring hash but has faster table lookup build times and host selection times. For more information about Maglev, see https://ai.google/research/pubs/pub44824 ORIGINAL_DESTINATION (166297216): Backend host is selected based on the client connection metadata, i.e., connections are opened to the same address as the destination address of the incoming connection before the connection was redirected to the load balancer. RANDOM (262527171): The load balancer selects a random healthy host. RING_HASH (432795069): The ring/modulo hash load balancer implements consistent hashing to backends. The algorithm has the property that the addition/removal of a host from a set of N hosts only affects 1/N of the requests. ROUND_ROBIN (153895801): This is a simple policy in which each healthy backend is selected in round robin order. This is the default. WEIGHTED_MAGLEV (254930962): Per-instance weighted Load Balancing via health check reported weights. If set, the Backend Service must configure a non legacy HTTP-based Health Check, and health check replies are expected to contain non-standard HTTP response header field X-Load-Balancing-Endpoint-Weight to specify the per-instance weights. If set, Load Balancing is weighted based on the per-instance weights reported in the last processed health check replies, as long as every instance either reported a valid weight or had UNAVAILABLE_WEIGHT. Otherwise, Load Balancing remains equal-weight. This option is only supported in Network Load Balancing.

MetadatasEntry

MetadatasEntry(mapping=None, *, ignore_unknown_fields=False, **kwargs)

The abstract base class for a message.

Parameters
NameDescription
kwargs dict

Keys and values corresponding to the fields of the message.

mapping Union[dict, .Message]

A dictionary or message to be used to determine the values for this message.

ignore_unknown_fields Optional(bool)

If True, do not raise errors for unknown fields. Only applied if mapping is a mapping type or there are keyword parameters.

Protocol

Protocol(value)

The protocol this BackendService uses to communicate with backends. Possible values are HTTP, HTTPS, HTTP2, TCP, SSL, UDP or GRPC. depending on the chosen load balancer or Traffic Director configuration. Refer to the documentation for the load balancers or for Traffic Director for more information. Must be set to GRPC when the backend service is referenced by a URL map that is bound to target gRPC proxy.

Values: UNDEFINED_PROTOCOL (0): A value indicating that the enum field is not set. GRPC (2196510): gRPC (available for Traffic Director). HTTP (2228360): No description available. HTTP2 (69079210): HTTP/2 with SSL. HTTPS (69079243): No description available. SSL (82412): TCP proxying with SSL. TCP (82881): TCP proxying or TCP pass-through. UDP (83873): UDP. UNSPECIFIED (526786327): If a Backend Service has UNSPECIFIED as its protocol, it can be used with any L3/L4 Forwarding Rules.

SessionAffinity

SessionAffinity(value)

Type of session affinity to use. The default is NONE. Only NONE and HEADER_FIELD are supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. For more details, see: Session Affinity <https://cloud.google.com/load-balancing/docs/backend-service#session_affinity>__.

Values: UNDEFINED_SESSION_AFFINITY (0): A value indicating that the enum field is not set. CLIENT_IP (345665051): 2-tuple hash on packet's source and destination IP addresses. Connections from the same source IP address to the same destination IP address will be served by the same backend VM while that VM remains healthy. CLIENT_IP_NO_DESTINATION (106122516): 1-tuple hash only on packet's source IP address. Connections from the same source IP address will be served by the same backend VM while that VM remains healthy. This option can only be used for Internal TCP/UDP Load Balancing. CLIENT_IP_PORT_PROTO (221722926): 5-tuple hash on packet's source and destination IP addresses, IP protocol, and source and destination ports. Connections for the same IP protocol from the same source IP address and port to the same destination IP address and port will be served by the same backend VM while that VM remains healthy. This option cannot be used for HTTP(S) load balancing. CLIENT_IP_PROTO (25322148): 3-tuple hash on packet's source and destination IP addresses, and IP protocol. Connections for the same IP protocol from the same source IP address to the same destination IP address will be served by the same backend VM while that VM remains healthy. This option cannot be used for HTTP(S) load balancing. GENERATED_COOKIE (370321204): Hash based on a cookie generated by the L7 loadbalancer. Only valid for HTTP(S) load balancing. HEADER_FIELD (200737960): The hash is based on a user specified header field. HTTP_COOKIE (494981627): The hash is based on a user provided cookie. NONE (2402104): No session affinity. Connections from the same client IP may go to any instance in the pool.