# Advice on cluster setup

**URL:** <https://discuss.elastic.co/t/advice-on-cluster-setup/6531>\
**Category:** Elasticsearch\
**Created:** [January 28, 2012, 12:43am UTC](https://discuss.elastic.co/t/advice-on-cluster-setup/6531 "2012-01-28T00:43:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shane\_Witbeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shane_witbeck/32/2803_2.png) [@Shane\_Witbeck](https://discuss.elastic.co/u/Shane_Witbeck)\
**Post date:** [January 28, 2012, 12:43am UTC](https://discuss.elastic.co/t/advice-on-cluster-setup/6531/1 "2012-01-28T00:43:03Z")

</div>

I have 2 boxes in a cluster that are geographically diverse (one on east  
coast and one on west coast). The behavior I observe is that it does a  
round robin (I'm making an assumption here based on every other response  
time being much slower). Is there a way to configure the cluster so all  
queries go to the master and only get routed to the non-master (further  
away, less performant) if there's a failure on the master?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 29, 2012, 6:22pm UTC](https://discuss.elastic.co/t/advice-on-cluster-setup/6531/2 "2012-01-29T18:22:29Z")

</div>

The elected master node is not related to where queries are routed. Same for elected primary shards. Searches are round robin between shard copies. You can control it by using shard allocation awareness (which will come handy when you have more nodes in the cluster to make sure copies of the shards are allocated properly across the two zones) which will also make sure that requests will go first to shards in their own zone. More info here: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/modules/cluster.html).

On Saturday, January 28, 2012 at 2:43 AM, Shane Witbeck wrote:

> I have 2 boxes in a cluster that are geographically diverse (one on east coast and one on west coast). The behavior I observe is that it does a round robin (I'm making an assumption here based on every other response time being much slower). Is there a way to configure the cluster so all queries go to the master and only get routed to the non-master (further away, less performant) if there's a failure on the master?

---

<div class="post-metadata">

**Author:** ![Shane\_Witbeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shane_witbeck/32/2803_2.png) [@Shane\_Witbeck](https://discuss.elastic.co/u/Shane_Witbeck)\
**Post date:** [March 20, 2012, 2:46am UTC](https://discuss.elastic.co/t/advice-on-cluster-setup/6531/3 "2012-03-20T02:46:33Z")

</div>

What's the best way to determine which nodes/shards search requests are  
routed to? I'm experimenting with cluster.routing.allocation attributes.

On Sunday, January 29, 2012 1:22:29 PM UTC-5, kimchy wrote:

> The elected master node is not related to where queries are routed. Same  
> for elected primary shards. Searches are round robin between shard copies.  
> You can control it by using shard allocation awareness (which will come  
> handy when you have more nodes in the cluster to make sure copies of the  
> shards are allocated properly across the two zones) which will also make  
> sure that requests will go first to shards in their own zone. More info  
> here: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/modules/cluster.html).
> 
> On Saturday, January 28, 2012 at 2:43 AM, Shane Witbeck wrote:
> 
> I have 2 boxes in a cluster that are geographically diverse (one on east  
> coast and one on west coast). The behavior I observe is that it does a  
> round robin (I'm making an assumption here based on every other response  
> time being much slower). Is there a way to configure the cluster so all  
> queries go to the master and only get routed to the non-master (further  
> away, less performant) if there's a failure on the master?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 20, 2012, 10:59am UTC](https://discuss.elastic.co/t/advice-on-cluster-setup/6531/4 "2012-03-20T10:59:32Z")

</div>

The cluster state API gives a full breakdown of where shards are located on  
(or use elasticsearch-head). Is that what you are after?

On Tue, Mar 20, 2012 at 4:46 AM, Shane Witbeck [shane@digitalsanctum.com](mailto:shane@digitalsanctum.com)wrote:

> What's the best way to determine which nodes/shards search requests are  
> routed to? I'm experimenting with cluster.routing.allocation attributes.
> 
> On Sunday, January 29, 2012 1:22:29 PM UTC-5, kimchy wrote:
> 
> > The elected master node is not related to where queries are routed. Same  
> > for elected primary shards. Searches are round robin between shard copies.  
> > You can control it by using shard allocation awareness (which will come  
> > handy when you have more nodes in the cluster to make sure copies of the  
> > shards are allocated properly across the two zones) which will also make  
> > sure that requests will go first to shards in their own zone. More info  
> > here: [http://www](http://www).**[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/)**  
> > reference/modules/cluster.html[http://www.elasticsearch.org/guide/reference/modules/cluster.html](http://www.elasticsearch.org/guide/reference/modules/cluster.html)  
> > \*\*.
> > 
> > On Saturday, January 28, 2012 at 2:43 AM, Shane Witbeck wrote:
> > 
> > I have 2 boxes in a cluster that are geographically diverse (one on east  
> > coast and one on west coast). The behavior I observe is that it does a  
> > round robin (I'm making an assumption here based on every other response  
> > time being much slower). Is there a way to configure the cluster so all  
> > queries go to the master and only get routed to the non-master (further  
> > away, less performant) if there's a failure on the master?

---

<div class="post-metadata">

**Author:** ![Shane\_Witbeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shane_witbeck/32/2803_2.png) [@Shane\_Witbeck](https://discuss.elastic.co/u/Shane_Witbeck)\
**Post date:** [March 20, 2012, 12:13pm UTC](https://discuss.elastic.co/t/advice-on-cluster-setup/6531/5 "2012-03-20T12:13:09Z")

</div>

Not exactly, I'd like to be able to audit which nodes and/or shards search  
results are coming from.

While debugging I found the SearchResponse, which has getSuccessfulShards  
and getShardFailures methods. I think these will give me what I'm looking  
for.

Thanks.

On Tuesday, March 20, 2012 6:59:32 AM UTC-4, kimchy wrote:

> The cluster state API gives a full breakdown of where shards are located  
> on (or use elasticsearch-head). Is that what you are after?
> 
> On Tue, Mar 20, 2012 at 4:46 AM, Shane Witbeck wrote:
> 
> > What's the best way to determine which nodes/shards search requests are  
> > routed to? I'm experimenting with cluster.routing.allocation attributes.
> > 
> > On Sunday, January 29, 2012 1:22:29 PM UTC-5, kimchy wrote:
> > 
> > > The elected master node is not related to where queries are routed. Same  
> > > for elected primary shards. Searches are round robin between shard copies.  
> > > You can control it by using shard allocation awareness (which will come  
> > > handy when you have more nodes in the cluster to make sure copies of the  
> > > shards are allocated properly across the two zones) which will also make  
> > > sure that requests will go first to shards in their own zone. More info  
> > > here: [http://www](http://www).**[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/)**  
> > > reference/modules/cluster.html[http://www.elasticsearch.org/guide/reference/modules/cluster.html](http://www.elasticsearch.org/guide/reference/modules/cluster.html)  
> > > \*\*.
> > > 
> > > On Saturday, January 28, 2012 at 2:43 AM, Shane Witbeck wrote:
> > > 
> > > I have 2 boxes in a cluster that are geographically diverse (one on east  
> > > coast and one on west coast). The behavior I observe is that it does a  
> > > round robin (I'm making an assumption here based on every other response  
> > > time being much slower). Is there a way to configure the cluster so all  
> > > queries go to the master and only get routed to the non-master (further  
> > > away, less performant) if there's a failure on the master?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 20, 2012, 8:34pm UTC](https://discuss.elastic.co/t/advice-on-cluster-setup/6531/6 "2012-03-20T20:34:24Z")

</div>

If you set explain to true, you will also get as part of the search results  
(SearchHit) the shard and node it came from. Though not possibly all the  
shards/nodes the search executed on. Note, explain can be expensive, as it  
provides other information as well.

On Tue, Mar 20, 2012 at 2:13 PM, Shane Witbeck [shane@digitalsanctum.com](mailto:shane@digitalsanctum.com)wrote:

> Not exactly, I'd like to be able to audit which nodes and/or shards search  
> results are coming from.
> 
> While debugging I found the SearchResponse, which has getSuccessfulShards  
> and getShardFailures methods. I think these will give me what I'm looking  
> for.
> 
> Thanks.
> 
> On Tuesday, March 20, 2012 6:59:32 AM UTC-4, kimchy wrote:
> 
> > The cluster state API gives a full breakdown of where shards are located  
> > on (or use elasticsearch-head). Is that what you are after?
> > 
> > On Tue, Mar 20, 2012 at 4:46 AM, Shane Witbeck wrote:
> > 
> > > What's the best way to determine which nodes/shards search requests are  
> > > routed to? I'm experimenting with cluster.routing.allocation attributes.
> > > 
> > > On Sunday, January 29, 2012 1:22:29 PM UTC-5, kimchy wrote:
> > > 
> > > > The elected master node is not related to where queries are routed.  
> > > > Same for elected primary shards. Searches are round robin between shard  
> > > > copies. You can control it by using shard allocation awareness (which will  
> > > > come handy when you have more nodes in the cluster to make sure copies of  
> > > > the shards are allocated properly across the two zones) which will also  
> > > > make sure that requests will go first to shards in their own zone. More  
> > > > info here: [http://www](http://www). **elasticsearch**.org/guide/\*_reference/modules/_  
> > > > \*cluster.html[http://www.elasticsearch.org/guide/reference/modules/cluster.html](http://www.elasticsearch.org/guide/reference/modules/cluster.html)  
> > > > \*\*.
> > > > 
> > > > On Saturday, January 28, 2012 at 2:43 AM, Shane Witbeck wrote:
> > > > 
> > > > I have 2 boxes in a cluster that are geographically diverse (one on  
> > > > east coast and one on west coast). The behavior I observe is that it does a  
> > > > round robin (I'm making an assumption here based on every other response  
> > > > time being much slower). Is there a way to configure the cluster so all  
> > > > queries go to the master and only get routed to the non-master (further  
> > > > away, less performant) if there's a failure on the master?

---

<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, 3:35am UTC](https://discuss.elastic.co/t/advice-on-cluster-setup/6531/7 "2017-07-06T03:35:22Z")

</div>


