Updated on 2025-07-11 GMT+08:00

Enabling Sticky Session to Improve Accelerate Access

In e-commerce shopping and user login systems, maintaining a sticky session between the client and server is crucial for a seamless user experience. If requests from the same client are distributed to different backend servers, users may need to log in to different servers or operation progress may be interrupted. To address these issues, you can enable sticky session for a backend server group, so that the load balancer can identify the characteristics (such as IP addresses and cookies) of client requests and distribute requests with the same IP address or cookie to the same backend server. This can improve access efficiency and user experience.

Sticky Session

The sticky session types supported by each backend server group vary by protocol and load balancing algorithm. For details, see Table 1.
Table 1 Sticky session types supported by dedicated load balancers

Backend Server Group Protocol

Load Balancing Algorithm

Sticky Session Type

  • TCP
  • UDP

Weighted round robin

Source IP address

Weighted least connections

Source IP address

Source IP hash

Not supported

  • HTTP
  • HTTPS
  • GRPC

Weighted round robin

  • Load balancer cookie
  • Application cookie

Weighted least connections

  • Load balancer cookie
  • Application cookie

Source IP hash

Not supported

QUIC

Connection ID

Source IP address

Table 2 Sticky session types

Sticky Session Type

Description

Stickiness Duration (Minutes)

Scenarios Where Sticky Session Become Invalid

Source IP address

The source IP address of each request is calculated using the consistent hashing algorithm to obtain a unique hashing key, and all backend servers are numbered. The system allocates the requests from a client to a particular server based on the generated key. This allows requests from the same IP address are forwarded to the same backend server.

  • Default: 20
  • Maximum: 60
  • Range: 1–60
  • Source IP addresses of the clients have changed.
  • The session stickiness duration has been reached.

Load balancer cookie

The load balancer generates a cookie after it receives a request from a client. All the subsequent requests with the same cookie are distributed to the same backend server.

  • Default: 20
  • Maximum: 1,440
  • Range: 1–1,440
  • Sticky sessions do not take effect when requests sent by the clients do not contain cookies.
  • The session stickiness duration has been reached.

Application cookie

The application deployed on the backend server generates a cookie after receiving the first request from the client. All subsequent requests with the cookie are routed to the same backend server.

  • If you set Load Balancing Algorithm to Source IP hash, you do not need to manually enable and configure Sticky Session. Source IP hash allows requests from the same client to be directed to the same server.
  • If you set Load Balancing Algorithm to Weighted round robin or Weighted least connections, you need to manually enable and configure Sticky Session.

Constraints

  • If you use Cloud Connect connection, Direct Connect or VPN to access ELB, you must select Source IP hash as the load balancing algorithm and disable sticky sessions for ELB.
  • Sticky session is enabled by default and is not shown for QUIC backend server groups.
  • Dedicated load balancers support Source IP address, Application cookie, and Load balancer cookie.
  • Application cookie will be available in more regions. You can see which regions support them on the console.
  • For HTTP and HTTPS listeners, enabling or disabling sticky sessions may cause few seconds of service interruption.
  • If you enable sticky sessions, traffic to backend servers may be unbalanced. If this happens, disable sticky sessions and check the requests received by each backend server.

Enabling or Disabling Sticky Session

  1. Go to the backend server group list page.
  2. On the Backend Server Groups page, locate the backend server group and click Edit in the Operation column.
  3. In the Modify Backend Server Group dialog box, enable or disable Sticky Session.

    If you enable it, select the sticky session type, and set the session stickiness duration.

  4. Click OK.