Reputation: 493
I'm referring How Can I use Apache to load balance Marklogic Cluster for some advice, but haven't got the idea.
Our MarkLogic Server version 8.0-4, and marklogic-client-api version is 4.1.0
There is a official way to config the MarkLogic Clinet
DatabaseClientFactory.newClient(host, port, new DigestAuthContext(user, passwd));
The config for the client is easy to understand. And it can work for me in our project.
But, for the host
, I'm a bit confused.
We have three hosts in our PORD. In MarkLogic config page, I can find below summary:
I only know this config in marklogic-client-api
.newClient("qwelap1", "8888", new DigestAuthContext("admin", "admin"));
Can I call three servers not just one server ? Should I use other framework to implement this or something others?
Upvotes: 1
Views: 205
Reputation: 3732
If you have a load balancer between your code and MarkLogic then use the load balancer hostname or IP in your newClient call. If the load balancer is between your code and the outside then use the hostname of any one of the servers. In common configurations it doesn't matter much which ML host you connect to.
I highly recommend you avoid calling API's that implicitly or explicitly leave transactions open between calls. It can be difficult or impossible to configure load balancers to reliably implement session affinity required for cross-request transactions. Best to assume that the load balancers do not implement affinity and work with that constraint at the client code.
Upvotes: 2