# How to use a load balancer with Elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-to-use-a-load-balancer-with-elasticsearch/72>\
**Category:** Elasticsearch\
**Created:** [April 30, 2015, 11:20pm UTC](https://discuss.elastic.co/t/how-to-use-a-load-balancer-with-elasticsearch/72 "2015-04-30T23:20:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [April 30, 2015, 11:20pm UTC](https://discuss.elastic.co/t/how-to-use-a-load-balancer-with-elasticsearch/72/1 "2015-04-30T23:20:26Z")

</div>

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](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` and `StaticConnectionPool`): [http://nest.azurewebsites.net/elasticsearch-net/connecting.html](http://nest.azurewebsites.net/elasticsearch-net/connecting.html) and [http://nest.azurewebsites.net/elasticsearch-net/cluster-failover.html](http://nest.azurewebsites.net/elasticsearch-net/cluster-failover.html). For example, in your application that calls [ES.net](http://ES.net), you can define a `SniffingConnectionPool` with a list of seed URLs for the nodes when you establish the ES connection. With a `SniffingConnectionPool` 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 your [`ConnectionSettings`](http://nest.azurewebsites.net/nest/connecting.html) to achieve the same. This is a pretty straightforward way to implement load balancing type of feature in Elasticsearch.

---

<div class="post-metadata">

**Author:** ![mosiddi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mosiddi/32/577_2.png) [@mosiddi](https://discuss.elastic.co/u/mosiddi)\
**Post date:** [June 7, 2015, 2:35pm UTC](https://discuss.elastic.co/t/how-to-use-a-load-balancer-with-elasticsearch/72/2 "2015-06-07T14:35:58Z")

</div>

We had ES cluster in Azure where we were initially leveraging Azure's Internal Load Balancer but we moved away from that and use NEST now. It just works fine 😄

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [May 25, 2017, 2:56pm UTC](https://discuss.elastic.co/t/how-to-use-a-load-balancer-with-elasticsearch/72/3 "2017-05-25T14:56:48Z")

</div>

I am interested in this. i am indexing lot of docs using NEST and reaching some limitations and connection refused by 1 node. If i have 2 es nodes is it better to put a linux loadbalancer in front of them or use NEST? Buf if using NEST you need to have 2 public ip address for the nodes right? if you just have one it is better to use the linux load balancing i guess.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:00pm UTC](https://discuss.elastic.co/t/how-to-use-a-load-balancer-with-elasticsearch/72/4 "2017-07-05T22:00:02Z")

</div>


