Configuring Sticky Sessions for Your Load Balancers
You can create a sticky session policy to bind the session of a user to a specific back-end instance.
This policy can be based on a specific duration, or controlled by an application of the instance. For more information, see About Load Balancers > Sticky Sessions.
After creating the policy, you must enable it for it to apply.
Create or Enable the Sticky Session Policy Using OSC CLI
Create the Sticky Session Policy
Before you begin: Ensure your load balancer has a listener for the HTTP or HTTPS protocols, as sticky sessions can be configured for these protocols only. For more information, see Adding or Deleting Listeners. |
See the CreateLoadBalancerPolicy command sample in the documentation of the OUTSCALE API. |
Enable the Sticky Session Policy
Before you begin: Ensure your load balancer has a listener for the HTTP or HTTPS protocols, as sticky sessions can be configured for these protocols only. For more information, see Adding or Deleting Listeners. |
See the UpdateLoadBalancerPolicy command sample in the documentation of the OUTSCALE API. |
Create or Enable the Sticky Session Policy Using AWS CLI
Create the Sticky Session Policy
Creating Duration-Based Sticky Sessions
Before you begin: Ensure your load balancer has a listener for the HTTP or HTTPS protocols, as sticky sessions can be configured for these protocols only. For more information, see Adding or Deleting Listeners. |
To create a duration-based sticky session policy, use the create-lb-cookie-stickiness-policy command following this syntax:
$ aws elb create-lb-cookie-stickiness-policy \
--profile YOUR_PROFILE \
--load-balancer-name LOAD_BALANCER_NAME \
--policy-name POLICY_NAME \
--cookie-expiration-period 3600 \
--endpoint https://lbu.eu-west-2.outscale.com
This command contains the following attributes that you need to specify:
-
(optional)
profile
: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI. -
load-balancer-name
: The name of the load balancer for which you want to configure the policy. -
policy-name
: A name for the policy.This name must consist of alphanumerical characters and dashes (-).
-
(optional)
cookie-expiration-period
: The duration of the sticky session, in seconds.This duration must be greater than 0. By default, the value is 1, which means that the sticky session lasts for the duration of the browser session.
-
endpoint
: The endpoint corresponding to the Region you want to send the request to.
The duration-based sticky session policy is created for the specified load balancer.
Creating Application-Controlled Sticky Sessions
Before you begin: Ensure your load balancer has a listener for the HTTP or HTTPS protocols, as sticky sessions can be configured for these protocols only. For more information, see Adding or Deleting Listeners. |
To create an application-controlled sticky session policy, use the create-app-cookie-stickiness-policy command following this syntax:
$ aws elb create-app-cookie-stickiness-policy \
--profile YOUR_PROFILE \
--load-balancer-name LOAD_BALANCER_NAME \
--policy-name POLICY_NAME \
--cookie-name COOKIE_NAME \
--endpoint https://lbu.eu-west-2.outscale.com
This command contains the following attributes that you need to specify:
-
(optional)
profile
: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI. -
load-balancer-name
: The name of the load balancer for which you want to configure the policy. -
policy-name
: A name for the policy.This name must consist of alphanumerical characters and dashes (-).
-
cookie-name
: The name of the application cookie used for stickiness. -
endpoint
: The endpoint corresponding to the Region you want to send the request to.
The application-controlled sticky session policy is created for the specified load balancer.
Enable the Sticky Session Policy
To enable the sticky session policy, use the set-load-balancer-policies-of-listener command following this syntax:
$ aws elb set-load-balancer-policies-of-listener \
--profile YOUR_PROFILE \
--load-balancer-name LOAD_BALANCER_NAME \
--load-balancer-port 80 \
--policy-names POLICY_NAME \
--endpoint https://lbu.eu-west-2.outscale.com
This command contains the following attributes that you need to specify:
-
(optional)
profile
: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI. -
load-balancer-name
: The name of the load balancer for which you want to enable the policy. -
load-balancer-port
: The external port of the load balancer (between 1 and 65535, both included). -
policy-names
: The name of the policy you want to enable for the listener.-
Only one policy can be active at a time. If there is already a policy enabled for the listener, the new one you specify replaces it.
-
To disable an enabled policy, specify
[]
for this parameter.
-
-
endpoint
: The endpoint corresponding to the Region you want to send the request to.
The sticky session policy is enabled for the specified load balancer.
Related Pages
Corresponding API Methods
AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.