When a single WSO2 product is providing a service, a session object is created and remains in the memory of the WSO2 product. However, in a clustered environment, where you could have multiple WSO2 product servers fronted by a load balancer to balance the load among these products, the situation is a little different.
If WSO2 server A does task X, WSO2 server B does task Y and WSO2 server C does task Z, and each one has a session object, there is no way for one WSO2 server to know what the other is doing. So, in order to synchronize between these servers, sticky sessions are used.
A sticky session ensures that all interactions with the WSO2 servers happen on one product server only, even though there are other WSO2 product servers present in the cluster. So the session object will be the same for the duration of the interaction. For more information, see Sticky Sessions with Manager Nodes.
Applying Sticky Session
Sticky Sessions are applied in WSO2 Mesos Artifacts by default. Follow the instructions below only if you need to customize the default sticky session.
Update the Mesos Artifacts and Puppet Hiera data as following to enable sticky sessions:
Step 1 - Update the Mesos Artifacts
- Download WSO2 Mesos Artifacts 1.0.0 distribution from the GitHub repository.
Unzip the distribution to a place of your choice. Let's refer to this location as
Sticky sessions can be configured by adding the following
labelsto the application definition.
For example, consider an application with following port mappings:
Based on the above example, if Port 9443 needs to be configured with sticky session, as the port index for port 9443 is 2 (as the port index starts with 0) the following labels are required to enable sticky sessions. Furthermore, note that
HAPROXY_2_implies that the settings are applied to the port index 2 (i.e., the 9443 port).
For a detailed description on the above labels, see the marathon-lb documentation.
The following are the corresponding HAProxy configs which are generated in the
Step 2 - Update in the Puppet Modules
- Download the Puppet Modules and copy the required packs into the modules by following the steps 1.1 and 1.2 which are described in the Build the Product Docker image section for this purpose.ation as
Configure the following Hiera data in the
<PUPPET_HOME>/hieradata/dev/platform/mesos.yamlfile to enable the sticky session.
Step 3 - Build the Docker image
How Sticky Session Works
WSO2 Mesos Artifacts ships a custom Docker image with preloaded self-signed certificate. This certificate is used to verify the SSL connection between the WSO2 server and the Marathon load balancer. Puppet adds this certificate to the
client-trust-store.jks at the time the Docker image is built.