Reference documentation and code samples for the Google Cloud Compute V1 API class Google::Cloud::Compute::V1::WeightedBackendService.
In contrast to a single BackendService in HttpRouteAction to which all matching traffic is directed to, WeightedBackendService allows traffic to be split across multiple backend services. The volume of traffic for each backend service is proportional to the weight specified in each WeightedBackendService
Inherits
Object
Extended By
Google::Protobuf::MessageExts::ClassMethods
Includes
Google::Protobuf::MessageExts
Methods
#backend_service
defbackend_service()->::String
Returns
(::String) — The full or partial URL to the default BackendService resource. Before forwarding the request to backendService, the load balancer applies any relevant headerActions specified as part of this backendServiceWeight.
#backend_service=
defbackend_service=(value)->::String
Parameter
value (::String) — The full or partial URL to the default BackendService resource. Before forwarding the request to backendService, the load balancer applies any relevant headerActions specified as part of this backendServiceWeight.
Returns
(::String) — The full or partial URL to the default BackendService resource. Before forwarding the request to backendService, the load balancer applies any relevant headerActions specified as part of this backendServiceWeight.
(::Google::Cloud::Compute::V1::HttpHeaderAction) — Specifies changes to request and response headers that need to take effect for the selected backendService. headerAction specified here take effect before headerAction in the enclosing HttpRouteRule, PathMatcher and UrlMap. headerAction is not supported for load balancers that have their loadBalancingScheme set to EXTERNAL. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true.
value (::Google::Cloud::Compute::V1::HttpHeaderAction) — Specifies changes to request and response headers that need to take effect for the selected backendService. headerAction specified here take effect before headerAction in the enclosing HttpRouteRule, PathMatcher and UrlMap. headerAction is not supported for load balancers that have their loadBalancingScheme set to EXTERNAL. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true.
Returns
(::Google::Cloud::Compute::V1::HttpHeaderAction) — Specifies changes to request and response headers that need to take effect for the selected backendService. headerAction specified here take effect before headerAction in the enclosing HttpRouteRule, PathMatcher and UrlMap. headerAction is not supported for load balancers that have their loadBalancingScheme set to EXTERNAL. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true.
#weight
defweight()->::Integer
Returns
(::Integer) — Specifies the fraction of traffic sent to a backend service, computed as weight / (sum of all weightedBackendService weights in routeAction) . The selection of a backend service is determined only for new traffic. Once a user's request has been directed to a backend service, subsequent requests are sent to the same backend service as determined by the backend service's session affinity policy. Don't configure session affinity if you're using weighted traffic splitting. If you do, the weighted traffic splitting configuration takes precedence. The value must be from 0 to 1000.
#weight=
defweight=(value)->::Integer
Parameter
value (::Integer) — Specifies the fraction of traffic sent to a backend service, computed as weight / (sum of all weightedBackendService weights in routeAction) . The selection of a backend service is determined only for new traffic. Once a user's request has been directed to a backend service, subsequent requests are sent to the same backend service as determined by the backend service's session affinity policy. Don't configure session affinity if you're using weighted traffic splitting. If you do, the weighted traffic splitting configuration takes precedence. The value must be from 0 to 1000.
Returns
(::Integer) — Specifies the fraction of traffic sent to a backend service, computed as weight / (sum of all weightedBackendService weights in routeAction) . The selection of a backend service is determined only for new traffic. Once a user's request has been directed to a backend service, subsequent requests are sent to the same backend service as determined by the backend service's session affinity policy. Don't configure session affinity if you're using weighted traffic splitting. If you do, the weighted traffic splitting configuration takes precedence. The value must be from 0 to 1000.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[],[],null,["# Google Cloud Compute V1 API - Class Google::Cloud::Compute::V1::WeightedBackendService (v3.0.0)\n\nVersion latestkeyboard_arrow_down\n\n- [3.0.0 (latest)](/ruby/docs/reference/google-cloud-compute-v1/latest/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.22.0](/ruby/docs/reference/google-cloud-compute-v1/2.22.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.21.1](/ruby/docs/reference/google-cloud-compute-v1/2.21.1/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.20.0](/ruby/docs/reference/google-cloud-compute-v1/2.20.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.19.1](/ruby/docs/reference/google-cloud-compute-v1/2.19.1/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.18.0](/ruby/docs/reference/google-cloud-compute-v1/2.18.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.17.0](/ruby/docs/reference/google-cloud-compute-v1/2.17.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.16.0](/ruby/docs/reference/google-cloud-compute-v1/2.16.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.15.0](/ruby/docs/reference/google-cloud-compute-v1/2.15.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.14.0](/ruby/docs/reference/google-cloud-compute-v1/2.14.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.13.0](/ruby/docs/reference/google-cloud-compute-v1/2.13.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.12.0](/ruby/docs/reference/google-cloud-compute-v1/2.12.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.11.0](/ruby/docs/reference/google-cloud-compute-v1/2.11.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.10.0](/ruby/docs/reference/google-cloud-compute-v1/2.10.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.9.0](/ruby/docs/reference/google-cloud-compute-v1/2.9.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.8.0](/ruby/docs/reference/google-cloud-compute-v1/2.8.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.7.2](/ruby/docs/reference/google-cloud-compute-v1/2.7.2/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.6.0](/ruby/docs/reference/google-cloud-compute-v1/2.6.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.5.0](/ruby/docs/reference/google-cloud-compute-v1/2.5.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.4.0](/ruby/docs/reference/google-cloud-compute-v1/2.4.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.3.0](/ruby/docs/reference/google-cloud-compute-v1/2.3.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.2.0](/ruby/docs/reference/google-cloud-compute-v1/2.2.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.1.0](/ruby/docs/reference/google-cloud-compute-v1/2.1.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [2.0.0](/ruby/docs/reference/google-cloud-compute-v1/2.0.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [1.10.0](/ruby/docs/reference/google-cloud-compute-v1/1.10.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [1.9.0](/ruby/docs/reference/google-cloud-compute-v1/1.9.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [1.8.0](/ruby/docs/reference/google-cloud-compute-v1/1.8.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [1.7.1](/ruby/docs/reference/google-cloud-compute-v1/1.7.1/Google-Cloud-Compute-V1-WeightedBackendService)\n- [1.6.0](/ruby/docs/reference/google-cloud-compute-v1/1.6.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [1.5.0](/ruby/docs/reference/google-cloud-compute-v1/1.5.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [1.4.0](/ruby/docs/reference/google-cloud-compute-v1/1.4.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [1.3.0](/ruby/docs/reference/google-cloud-compute-v1/1.3.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [1.2.0](/ruby/docs/reference/google-cloud-compute-v1/1.2.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [1.1.0](/ruby/docs/reference/google-cloud-compute-v1/1.1.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [1.0.0](/ruby/docs/reference/google-cloud-compute-v1/1.0.0/Google-Cloud-Compute-V1-WeightedBackendService)\n- [0.5.0](/ruby/docs/reference/google-cloud-compute-v1/0.5.0/Google-Cloud-Compute-V1-WeightedBackendService) \nReference documentation and code samples for the Google Cloud Compute V1 API class Google::Cloud::Compute::V1::WeightedBackendService.\n\nIn contrast to a single BackendService in HttpRouteAction to which all matching traffic is directed to, WeightedBackendService allows traffic to be split across multiple backend services. The volume of traffic for each backend service is proportional to the weight specified in each WeightedBackendService \n\nInherits\n--------\n\n- Object \n\nExtended By\n-----------\n\n- Google::Protobuf::MessageExts::ClassMethods \n\nIncludes\n--------\n\n- Google::Protobuf::MessageExts\n\nMethods\n-------\n\n### #backend_service\n\n def backend_service() -\u003e ::String\n\n**Returns**\n\n- (::String) --- The full or partial URL to the default BackendService resource. Before forwarding the request to backendService, the load balancer applies any relevant headerActions specified as part of this backendServiceWeight.\n\n### #backend_service=\n\n def backend_service=(value) -\u003e ::String\n\n**Parameter**\n\n- **value** (::String) --- The full or partial URL to the default BackendService resource. Before forwarding the request to backendService, the load balancer applies any relevant headerActions specified as part of this backendServiceWeight. \n**Returns**\n\n- (::String) --- The full or partial URL to the default BackendService resource. Before forwarding the request to backendService, the load balancer applies any relevant headerActions specified as part of this backendServiceWeight.\n\n### #header_action\n\n def header_action() -\u003e ::Google::Cloud::Compute::V1::HttpHeaderAction\n\n**Returns**\n\n- ([::Google::Cloud::Compute::V1::HttpHeaderAction](./Google-Cloud-Compute-V1-HttpHeaderAction)) --- Specifies changes to request and response headers that need to take effect for the selected backendService. headerAction specified here take effect before headerAction in the enclosing HttpRouteRule, PathMatcher and UrlMap. headerAction is not supported for load balancers that have their loadBalancingScheme set to EXTERNAL. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true.\n\n### #header_action=\n\n def header_action=(value) -\u003e ::Google::Cloud::Compute::V1::HttpHeaderAction\n\n**Parameter**\n\n- **value** ([::Google::Cloud::Compute::V1::HttpHeaderAction](./Google-Cloud-Compute-V1-HttpHeaderAction)) --- Specifies changes to request and response headers that need to take effect for the selected backendService. headerAction specified here take effect before headerAction in the enclosing HttpRouteRule, PathMatcher and UrlMap. headerAction is not supported for load balancers that have their loadBalancingScheme set to EXTERNAL. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true. \n**Returns**\n\n- ([::Google::Cloud::Compute::V1::HttpHeaderAction](./Google-Cloud-Compute-V1-HttpHeaderAction)) --- Specifies changes to request and response headers that need to take effect for the selected backendService. headerAction specified here take effect before headerAction in the enclosing HttpRouteRule, PathMatcher and UrlMap. headerAction is not supported for load balancers that have their loadBalancingScheme set to EXTERNAL. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true.\n\n### #weight\n\n def weight() -\u003e ::Integer\n\n**Returns**\n\n- (::Integer) --- Specifies the fraction of traffic sent to a backend service, computed as weight / (sum of all weightedBackendService weights in routeAction) . The selection of a backend service is determined only for new traffic. Once a user's request has been directed to a backend service, subsequent requests are sent to the same backend service as determined by the backend service's session affinity policy. Don't configure session affinity if you're using weighted traffic splitting. If you do, the weighted traffic splitting configuration takes precedence. The value must be from 0 to 1000.\n\n### #weight=\n\n def weight=(value) -\u003e ::Integer\n\n**Parameter**\n\n- **value** (::Integer) --- Specifies the fraction of traffic sent to a backend service, computed as weight / (sum of all weightedBackendService weights in routeAction) . The selection of a backend service is determined only for new traffic. Once a user's request has been directed to a backend service, subsequent requests are sent to the same backend service as determined by the backend service's session affinity policy. Don't configure session affinity if you're using weighted traffic splitting. If you do, the weighted traffic splitting configuration takes precedence. The value must be from 0 to 1000. \n**Returns**\n\n- (::Integer) --- Specifies the fraction of traffic sent to a backend service, computed as weight / (sum of all weightedBackendService weights in routeAction) . The selection of a backend service is determined only for new traffic. Once a user's request has been directed to a backend service, subsequent requests are sent to the same backend service as determined by the backend service's session affinity policy. Don't configure session affinity if you're using weighted traffic splitting. If you do, the weighted traffic splitting configuration takes precedence. The value must be from 0 to 1000."]]