# When a master node goes down, how the client query works?

**URL:** <https://discuss.elastic.co/t/when-a-master-node-goes-down-how-the-client-query-works/21064>\
**Category:** Elasticsearch\
**Created:** [December 3, 2014, 4:50pm UTC](https://discuss.elastic.co/t/when-a-master-node-goes-down-how-the-client-query-works/21064 "2014-12-03T16:50:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaron\_2](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@Aaron\_2](https://discuss.elastic.co/u/Aaron_2)\
**Post date:** [December 3, 2014, 4:50pm UTC](https://discuss.elastic.co/t/when-a-master-node-goes-down-how-the-client-query-works/21064/1 "2014-12-03T16:50:31Z")

</div>

This is a newbie question about how the cluster works. I try to find the  
answer from the group, but seems not exact the same question I have.  
By reading the guide from [elasticsearch.com](http://elasticsearch.com), I understand when a master  
node goes down, a new master node will be elected automatically. However, a  
client does not know that and he still tries to query the old master node.  
I was wondering what the result will be.

Assume I already have data indexed into 5 nodes, n1 to n5, where n1 is the  
original master node. so when the client queries, the client do something  
like: curl -XPOST "[http://n1:9200/movies/movie/\_search?q=\*:Godfather](http://n1:9200/movies/movie/_search?q=*:Godfather)",  
life is good so far.

When n1 node goes down, assume n2 becomes the new master node. Since the  
client does no know n1 is down, he still submits the same query to n1, what  
result will be returned?

Should a client query the cluster instead of querying a master node? How to  
submit a query to the cluster?

Thanks a lot in advance!

Aaron

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7b963b8c-625d-48eb-a75e-05a8ee4b53b3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7b963b8c-625d-48eb-a75e-05a8ee4b53b3%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![elvarb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elvarb/32/44840_2.png) [@elvarb](https://discuss.elastic.co/u/elvarb)\
**Post date:** [December 4, 2014, 12:58pm UTC](https://discuss.elastic.co/t/when-a-master-node-goes-down-how-the-client-query-works/21064/2 "2014-12-04T12:58:07Z")

</div>

Two options

1. Have a client instance of elasticsearch on a different server or on the  
same server that does the query. That node must be set to master=false and  
data=false. Being a member of the cluster means you know where the data is.
2. Use a http reverse proxy that connects to all the nodes in the cluster,  
if http 9200 is unavailable on one node then traffic is sent to the other  
nodes.

Best option is to combine the two. Have two elasticsearch nodes as client  
members of the cluster, install a reverse proxy on those two and  
loadbalance between them on the IP level with a solution of choice.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7e0c1382-399f-4a0b-ba77-59fa64c9ac2c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7e0c1382-399f-4a0b-ba77-59fa64c9ac2c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 4, 2014, 1:45pm UTC](https://discuss.elastic.co/t/when-a-master-node-goes-down-how-the-client-query-works/21064/3 "2014-12-04T13:45:59Z")

</div>

With Java client, you have not to worry about that. You have either  
multiple node connections or explicitly chosen the nodes to connect to  
(transport client).

With HTTP client, the official Elasticsearch clients provide methods to  
connect to multiple hosts. If one host goes down, the next one is chosen.

Jörg

On Wed, Dec 3, 2014 at 5:50 PM, Aaron [apptry.aaron@gmail.com](mailto:apptry.aaron@gmail.com) wrote:

> This is a newbie question about how the cluster works. I try to find the  
> answer from the group, but seems not exact the same question I have.  
> By reading the guide from [elasticsearch.com](http://elasticsearch.com), I understand when a master  
> node goes down, a new master node will be elected automatically. However, a  
> client does not know that and he still tries to query the old master node.  
> I was wondering what the result will be.
> 
> Assume I already have data indexed into 5 nodes, n1 to n5, where n1 is the  
> original master node. so when the client queries, the client do something  
> like: curl -XPOST "[http://n1:9200/movies/movie/\_search?q=\*:Godfather](http://n1:9200/movies/movie/_search?q=*:Godfather)",  
> life is good so far.
> 
> When n1 node goes down, assume n2 becomes the new master node. Since the  
> client does no know n1 is down, he still submits the same query to n1, what  
> result will be returned?
> 
> Should a client query the cluster instead of querying a master node? How  
> to submit a query to the cluster?
> 
> Thanks a lot in advance!
> 
> Aaron
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/7b963b8c-625d-48eb-a75e-05a8ee4b53b3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7b963b8c-625d-48eb-a75e-05a8ee4b53b3%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/7b963b8c-625d-48eb-a75e-05a8ee4b53b3%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7b963b8c-625d-48eb-a75e-05a8ee4b53b3%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoG3%2BJTkk7CaHKRqV%2BtSpUzshRC0Fv5y3dLPn%3DLr1Lq8hA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoG3%2BJTkk7CaHKRqV%2BtSpUzshRC0Fv5y3dLPn%3DLr1Lq8hA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Aaron\_2](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@Aaron\_2](https://discuss.elastic.co/u/Aaron_2)\
**Post date:** [December 5, 2014, 4:54am UTC](https://discuss.elastic.co/t/when-a-master-node-goes-down-how-the-client-query-works/21064/4 "2014-12-05T04:54:01Z")

</div>

Thank you both Elvar and Jorg for your replies.

Aaron

On Thursday, December 4, 2014 7:58:07 AM UTC-5, Elvar Böðvarsson wrote:

> Two options
> 
> 1. Have a client instance of elasticsearch on a different server or on the  
> same server that does the query. That node must be set to master=false and  
> data=false. Being a member of the cluster means you know where the data is.
> 2. Use a http reverse proxy that connects to all the nodes in the cluster,  
> if http 9200 is unavailable on one node then traffic is sent to the other  
> nodes.
> 
> Best option is to combine the two. Have two elasticsearch nodes as client  
> members of the cluster, install a reverse proxy on those two and  
> loadbalance between them on the IP level with a solution of choice.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a50ae28e-34c4-4369-a043-6cda5bf30fd2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a50ae28e-34c4-4369-a043-6cda5bf30fd2%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:45am UTC](https://discuss.elastic.co/t/when-a-master-node-goes-down-how-the-client-query-works/21064/5 "2017-07-06T00:45:41Z")

</div>


