Load Balancing in MarkLogic
18 June 2019 03:39 PM
If an application server is distributed across multiple nodes in a MarkLogic Server cluster, it is the responsibility of the client to evenly distribute query requests across the available nodes.
HTTP Load Balancing
To balance load for HTTP requests to a MarkLogic HTTP application server, customers will often use a HTTP load balancer in front of their MarkLogic cluster. Load balancers can take into account each node's processing load, response time, active connections, etc, but it is also common for the load balancer to be configured with a simple round robin scheduling algorithm.
XCC Load Balancing
XDBC is not HTTP precisely, but under the hood it is treated as HTTP. Typical XDBC Application level exchange
To use XCC applications with an HTTP load balancer, 1) Client : set
Please Note that - you need both of the above changes in order for XCC Multi Statement Transaction to work without error. It could be the scenario that for smaller load, your Load Balancer and XCC client without sticky session enable, may work for certain load depending upon a) if Multi Statement Transaction were used, and b) if Load Balancer for smaller load routed all traffic to same node; However, that is not a guarantee that it will work for all Multi Statement Transaction load.
Section 'Using a Load Balancer or Proxy Server with an XCC Application' contains important information for environments in which a Load Balancer or a proxy server sits between your XCC application and MarkLogic Server cluster.
TCP Load Balancing
TCP Load Balancer usually ignores peeking inside Application stack (HTTP/XCC application layer). As a result TCP Load Balancer are unaware of Session Id (if set), and application requirement to route the second statement to the same destination host where earlier statement (part of the some Multi Statement Transaction) may have been routed. Hence you may run into issues with XCC or any application relying on session id.
In that scenario, you should change Load Balancer to HTTP based Load Balancer.
Load Balancing with AWS
If you receive 504 Timeout errors, then the load balancer may be closing the connection before the server responds to the request. Ensure the idle time out setting is sufficient to receive responses from the MarkLogic server.