# Elasticsearch AWS availability zone awareness

**URL:** <https://discuss.elastic.co/t/elasticsearch-aws-availability-zone-awareness/13902>\
**Category:** Elasticsearch\
**Created:** [October 10, 2013, 8:37am UTC](https://discuss.elastic.co/t/elasticsearch-aws-availability-zone-awareness/13902 "2013-10-10T08:37:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicktgr15](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nicktgr15](https://discuss.elastic.co/u/nicktgr15)\
**Post date:** [October 10, 2013, 8:37am UTC](https://discuss.elastic.co/t/elasticsearch-aws-availability-zone-awareness/13902/1 "2013-10-10T08:37:51Z")

</div>

Hello,

I have a question regarding elasticsearch AWS availability zone awareness  
which I will attempt to describe with an example.  
Let's suppose that we have an elasticsearch cluster running on eu-west-1  
with 2 nodes (ec2 instances) per zone (3 availability zones, 6 nodes in  
total).  
To my understanding, in the event of a zone failure if shards were  
replicated between nodes of the same zone the cluster will not be  
able to completely recover.  
Is this the case or elasticsearch is aware of the AWS zones in a region and  
tries to replicate shards to nodes in different zones?

Regards,  
Nick

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [October 10, 2013, 12:22pm UTC](https://discuss.elastic.co/t/elasticsearch-aws-availability-zone-awareness/13902/2 "2013-10-10T12:22:24Z")

</div>

Correct. You need to configure awareness in order to make each area as  
independent as possible, so that you possibly have a whole copy of the data  
in each zone.

Have a look at the reference to know how to do  
it: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-cluster.html)  
.

Cheers  
Luca

On Thursday, October 10, 2013 10:37:51 AM UTC+2, nicktgr15 wrote:

> Hello,
> 
> I have a question regarding elasticsearch AWS availability zone awareness  
> which I will attempt to describe with an example.  
> Let's suppose that we have an elasticsearch cluster running on eu-west-1  
> with 2 nodes (ec2 instances) per zone (3 availability zones, 6 nodes in  
> total).  
> To my understanding, in the event of a zone failure if shards were  
> replicated between nodes of the same zone the cluster will not be  
> able to completely recover.  
> Is this the case or elasticsearch is aware of the AWS zones in a region  
> and tries to replicate shards to nodes in different zones?
> 
> Regards,  
> Nick

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![nicktgr15](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nicktgr15](https://discuss.elastic.co/u/nicktgr15)\
**Post date:** [October 11, 2013, 4:00pm UTC](https://discuss.elastic.co/t/elasticsearch-aws-availability-zone-awareness/13902/3 "2013-10-11T16:00:24Z")

</div>

Thanks for the quick reply Luca. It looks like what I was looking for.

Regards,  
Nick

On Thursday, October 10, 2013 1:22:24 PM UTC+1, Luca Cavanna wrote:

> Correct. You need to configure awareness in order to make each area as  
> independent as possible, so that you possibly have a whole copy of the data  
> in each zone.
> 
> Have a look at the reference to know how to do it:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-cluster.html).
> 
> Cheers  
> Luca
> 
> On Thursday, October 10, 2013 10:37:51 AM UTC+2, nicktgr15 wrote:
> 
> > Hello,
> > 
> > I have a question regarding elasticsearch AWS availability zone awareness  
> > which I will attempt to describe with an example.  
> > Let's suppose that we have an elasticsearch cluster running on eu-west-1  
> > with 2 nodes (ec2 instances) per zone (3 availability zones, 6 nodes in  
> > total).  
> > To my understanding, in the event of a zone failure if shards were  
> > replicated between nodes of the same zone the cluster will not be  
> > able to completely recover.  
> > Is this the case or elasticsearch is aware of the AWS zones in a region  
> > and tries to replicate shards to nodes in different zones?
> > 
> > Regards,  
> > Nick

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Pierce\_Wetter](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@Pierce\_Wetter](https://discuss.elastic.co/u/Pierce_Wetter)\
**Post date:** [October 11, 2013, 6:16pm UTC](https://discuss.elastic.co/t/elasticsearch-aws-availability-zone-awareness/13902/4 "2013-10-11T18:16:07Z")

</div>

We do this as follows:

Somewhere:

zone=`/usr/bin/curl -s /dev/null http://169.254.169.254/latest/meta-data/placement/availability-zone`  
export AWS\_ZONE=$zone

config/elasticsearch.yml:

node.awszone: ${AWS\_ZONE}  
cluster.routing.allocation.awareness.attributes: awszone

Gotchas:

You have to set the minimum master nodes to be 1 greater than the maximum  
number of nodes you have in a zone. That prevents elastic search from  
nominating a new primary unless it can see two zones.

That's because it turns out that zones lose communication with each other  
on a regular basis. Not for long, but long enough for Elasticsearch to  
detect it and split brain especially if you have it set to the default of

1. We have 4 zones, 6 nodes. 2 West zones of 2 nodes each, 2 East zones of  
1 node each. East would lose contact with West and split brain.

You need 0.90.5 at least, because there's a bug fix in there relating to  
allocating shards that wouldn't balance if you didn't have an equal number  
of nodes in each zone.

There may be an additional problem relating to primary allocation, as I now  
have all the primary shards on one node.

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:12am UTC](https://discuss.elastic.co/t/elasticsearch-aws-availability-zone-awareness/13902/5 "2017-07-06T02:12:49Z")

</div>


