Switching between the nodes in ElasticSearch using JEST client Switching between the nodes in ElasticSearch using JEST client elasticsearch elasticsearch

Switching between the nodes in ElasticSearch using JEST client


I would take a look at creating at what is known as a client node. A client node has node.data set to false, so while it is a full member of the cluster it stores no data locally. This both off-loads query processing from nodes handling document indexing and provides the beginnings of a load balancing approach.

The data-less node has significantly lower chance of failure, given that most software failure scenarios for Elasticsearch revolve around blowing out your JVM heap and that is much less likely when you are only doing query processing and not also maintaining indexes. Further, this approach can be extended to a type of local load balancer.

If you were to run your client node elasticsearch instance on your application server you effectively provide local load balancing. The node will send out the queries to all other nodes in the cluster that need to be included in a specific query. And since the software is running on the same server as your application software you eliminate the failure mode of the node you are connecting to failing while your app server is still up.

This architectural approach is discussed in some detail here:

https://blog.liip.ch/archive/2013/07/19/on-elasticsearch-performance.html

And a bit more here on client nodes:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-node.html

Alternatively, you could use the native Java Elasticsearch api which does not use the REST interface - this allows your Java application to connect as a member node of the cluster, in which case it will know about all the other nodes and will be able to route your queries to the correct node. I'd take a look at both the client node and the transport node approaches:

http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html#node-client

http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html#transport-client