lb/BP/2026_001

Backend Services with Session Affinity should not use UTILIZATION balancing mode.

Product: Cloud Load Balancing Rule class: BP - Best Practice

Description

Session affinity aims to send requests from the same client to the same backend. Misconfiguration with balancing modes, especially using UTILIZATION with session affinity, can lead to some backends being overloaded while others are underutilized, or cause sessions to break unexpectedly. This can negatively impact application performance and user experience.

When Session Affinity is enabled (e.g., CLIENT_IP, GENERATED_COOKIE, HTTP_COOKIE), the load balancer attempts to direct requests from the same client to the same backend. However, UTILIZATION mode distributes traffic based on the current utilization of backends. These two goals can conflict, potentially causing the load balancer to prioritize utilization targets over maintaining session affinity.

Remediation

If session affinity is required for the application:

  1. Avoid UTILIZATION balancing mode: Do not use UTILIZATION for any backend groups (Instance Groups or NEGs) within a Backend Service where session affinity is enabled.
  2. Use RATE or CONNECTION:
    • For HTTP, HTTPS, or HTTP/2 backend services, switch the balancing mode to RATE.
    • For TCP or SSL backend services, switch the balancing mode to CONNECTION.

You can modify the balancing mode using gcloud commands. Examples:

  • For HTTP(S) - Switch to RATE:

    gcloud compute backend-services update-backend YOUR-BACKEND-SERVICE \
        --instance-group=YOUR-INSTANCE-GROUP \
        --balancing-mode=RATE \
        --max-rate-per-instance=100 \
        --region=YOUR-REGION # Or --global
    
  • For TCP/SSL - Switch to CONNECTION:

    gcloud compute backend-services update-backend YOUR-BACKEND-SERVICE \
        --instance-group=YOUR-INSTANCE-GROUP \
        --balancing-mode=CONNECTION \
        --max-connections-per-instance=500 \
        --region=YOUR-REGION # Or --global
    
  1. Re-evaluate Necessity: Confirm if session affinity is strictly necessary. Stateless applications may not require it, simplifying the configuration.

Further information