For load balancing, there are actually a few out of the box solutions available without having to use an external load balancer.
- Elasticsearch also provides a light weight load balancer in the form of what we call a
client node
(http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-node.html#modules-node). This is a separate ES node (and will join your main cluster) that does not store any data and it is “smart”, meaning that it knows where the relevant data is stored, so it will automatically direct requests to the appropriate node(s) that store the data being requested. Once it receives the data back from the data nodes, the client node will reduce the result set and send back to the requestor. - If you are using the .NET client, you can use one of the available
IConnectionPool
types (eg.SniffingConnectionPool
andStaticConnectionPool
): http://nest.azurewebsites.net/elasticsearch-net/connecting.html and http://nest.azurewebsites.net/elasticsearch-net/cluster-failover.html. For example, in your application that calls ES.net, you can define aSniffingConnectionPool
with a list of seed URLs for the nodes when you establish the ES connection. With aSniffingConnectionPool
setting, the .NET client will sniff the cluster state to determine the list of "alive" nodes and round robin requests automatically between them. - If you are using the NEST client, you can similarly pass in the appropriate
IConnectionPool
type to yourConnectionSettings
to achieve the same. This is a pretty straightforward way to implement load balancing type of feature in Elasticsearch.