Community

MarkLogic 10 and Data Hub 5.0

Latest MarkLogic releases provide a smarter, simpler, and more secure way to integrate data.

Read Blog →

Company

Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up →

 
Knowledgebase: MarkLogic Server
Load Balancing in MarkLogic
18 June 2019 03:39 PM

Summary

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 

==============
POST /eval XDBC/1.0
Content-Type: application/x-www-form-urlencoded
Authorization: Digest username="admin", realm="public", nonce="4a1769886d0aa3749912bded934bc4c4", uri="/eval", qop="auth", nc="1", cnonce="446e3c3e42c5b6cc4791babdf4df5494", response="f3c3000bc04a0ba654356abda02a79dd", opaque="592754fbcbdb895e"
User-Agent: Java/1.8.0_72 MarkLogicXCC/8.0-4
Accept: application/vnd.marklogic.sequence, */*
Content-Length: 487
Connection: keep-alive


==============
XDBC/1.0 200 OK
Server: MarkLogic 8.0-4
Set-Cookie: TxnID=null; path=/
Content-Type: multipart/mixed; boundary=0f42f0026784ff0e
Content-Length: 120
Connection: Keep-Alive
Keep-Alive: timeout=5
==============


In previous releases of MarkLogic server, XCC applications were not supported with HTTP load balancer. However, since MarkLogic 7, it is now possible to run XCC applications against an HTTP load balancer

To use XCC applications with an HTTP load balancer, 1) Client : set xcc.httpcompliant to true in your XCC application and use the SessionId cookie to preserve session affinity, 2) Middle Layer/ Load Balancer: Configure HTTP Load Balancer to support sticky session (routing request based on session id cookies).

In general, When you use 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 queries evaluated in the context 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 or sticky sessions.

MarkLogic Server does require existing sessions to interact with the same E-node host. It is important that the load balancer is configured to use sticky sessions when interacting with MarkLogic Server so that existing sessions always communicate with the same host.

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.

(36 vote(s))
Helpful
Not helpful

Comments (0)