# Loadbalancer in front of Elasticsearch

**URL:** <https://discuss.elastic.co/t/loadbalancer-in-front-of-elasticsearch/59994>\
**Category:** Elasticsearch\
**Created:** [September 7, 2016, 2:11pm UTC](https://discuss.elastic.co/t/loadbalancer-in-front-of-elasticsearch/59994 "2016-09-07T14:11:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![blinduck](https://avatars.discourse-cdn.com/v4/letter/b/87869e/32.png) [@blinduck](https://discuss.elastic.co/u/blinduck)\
**Post date:** [September 7, 2016, 2:11pm UTC](https://discuss.elastic.co/t/loadbalancer-in-front-of-elasticsearch/59994/1 "2016-09-07T14:11:10Z")

</div>

Hello,

I've got a 5 data, 3 master node setup. I understand that elasticsearch has built in load balancing capability, and that I could just route all the traffic to one of the nodes and call it a day.

I've seen several articles talking about setting up a load balancer infront of elasticsearch to increase availability, in case the node I'm routing traffic to goes down.

I can't find anything about this in the official documentation. Can anyone chime in on the best setup from a performance perspective?

Also would love to hear if anyone knows of how I would actually scientifically test the performance of these different setups..

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [September 7, 2016, 2:44pm UTC](https://discuss.elastic.co/t/loadbalancer-in-front-of-elasticsearch/59994/2 "2016-09-07T14:44:09Z")

</div>

If you are using one of the official language clients (strongly recommended) then it can 'sniff' your cluster and locate all the nodes when you connect so that in the case that the node it was using to connect to the cluster goes down it can switch to another node. In addition it is recommended to give the clients a few (maybe 3) nodes as a seed list in case one of the nodes is down when it first tries to connect before its completed the 'sniffing'. This removes the need for a load balancer in front of Elasticsearch to deal with node failures.

hope that helps

---

<div class="post-metadata">

**Author:** ![MarkOStewart](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@MarkOStewart](https://discuss.elastic.co/u/MarkOStewart)\
**Post date:** [September 8, 2016, 12:05am UTC](https://discuss.elastic.co/t/loadbalancer-in-front-of-elasticsearch/59994/3 "2016-09-08T00:05:01Z")

</div>

We use HAproxy and RoundRobin forward rest calls to the client nodes http port and java\_transport client code calls to the transfer ports.

---

<div class="post-metadata">

**Author:** ![kstaken](https://avatars.discourse-cdn.com/v4/letter/k/e68b1a/32.png) [@kstaken](https://discuss.elastic.co/u/kstaken)\
**Post date:** [September 8, 2016, 9:51pm UTC](https://discuss.elastic.co/t/loadbalancer-in-front-of-elasticsearch/59994/4 "2016-09-08T21:51:28Z")

</div>

As mentioned the official clients deal with this pretty well but also be aware that if you send all search/indexing traffic through a single node (and that node is also a data node) it will be carrying a disproportionate load and if you have a high volume of searches the node will be at elevated risk of heap related issues. It's a very good idea to spread everything around if at all possible.

Kimbro

---

<div class="post-metadata">

**Author:** ![blinduck](https://avatars.discourse-cdn.com/v4/letter/b/87869e/32.png) [@blinduck](https://discuss.elastic.co/u/blinduck)\
**Post date:** [September 13, 2016, 11:04am UTC](https://discuss.elastic.co/t/loadbalancer-in-front-of-elasticsearch/59994/5 "2016-09-13T11:04:17Z")

</div>

Thanks, I decided to go with this approach, seems to be working fine.

---

<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:20pm UTC](https://discuss.elastic.co/t/loadbalancer-in-front-of-elasticsearch/59994/6 "2017-07-05T22:20:47Z")

</div>


