Knowledgebase:
Sticky Session and Session cookie to configure in Load Balancer
14 March 2024 02:26 PM

What is Sticky session and why is it needed?

For client applications that use multi-statement transactions and interact with a MarkLogic Server cluster through a load balancer, it is possible for requests from your application to MarkLogic Server to be routed to different hosts, even within the same session.

This has no effect on most interactions with MarkLogic Server, but operations that are part of the same multi-statement transaction need to be routed to the same host within your MarkLogic cluster. This consistent routing through a load balancer is called session affinity.

How to configure Sticky Session?

Most load balancers provide a mechanism that supports session affinity. This usually takes the form of a session cookie that originates on the load balancer. The client acquires the cookie from the load balancer, and passes it on any requests that belong to the session. The exact steps required to configure a load balancer to generate session cookies depends on the load balancer. Consult your load balancer documentation for details.

For the applications using Java CLIENT API, configure HostId cookie in your requests to preserve session affinity. 

For XCC applications, configure SessionID cookie to preserve session affinity.

Configure these cookies on your Load balancer session affinity configuration for the specific port on which your application is communicating to MarkLogic cluster.

(2 vote(s))
Helpful
Not helpful

Comments (0)