From 8c4ea94717c2deb721f6be18ec28c17e5bb88cd9 Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Mon, 16 Sep 2024 13:15:35 +0530 Subject: [PATCH] Added more details regarding shard allocation awareness attributes Signed-off-by: Smit Patel --- _tuning-your-cluster/index.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/_tuning-your-cluster/index.md b/_tuning-your-cluster/index.md index 99db78565fc..456314ac464 100644 --- a/_tuning-your-cluster/index.md +++ b/_tuning-your-cluster/index.md @@ -194,7 +194,11 @@ To better understand and monitor your cluster, use the [CAT API]({{site.url}}{{s ### Shard allocation awareness -If your nodes are spread across several geographical zones, you can configure shard allocation awareness to allocate all replica shards to a zone that’s different from their primary shard. +You can set custom node attributes on Opensearch nodes to be used for shard allocation. + +For example, you can set the `zone` attribute on each node to represent the zone in which the node is located and use this attribute as shard allocation awareness attribute to ensure that primary and its replica shards are allocated in a balanced manner across available distinct zones i.e. maximum shard copies per zone = ceil (number of shard copies / number of distinct zones). + +If your index has total 5 shard copies (1 primary and 4 replicas) and nodes in only 3 distinct zones, then OpenSearch will not allocate more than 2 shards per zone, so you need atleast 2 nodes in 2 zones each and atleast 1 node in the 3rd zone to allocate all 5 shard copies. If you have 3 nodes in 1st zone and 1 node in remaining zones each, then OpenSearch will only allocate 2,1,1 shard copies leaving the 5th copy unallocated. With shard allocation awareness, if the nodes in one of your zones fail, you can be assured that your replica shards are spread across your other zones. It adds a layer of fault tolerance to ensure your data survives a zone failure beyond just individual node failures. @@ -219,6 +223,8 @@ PUT _cluster/settings } ``` +You can also use multiple attributes as the shard allocation awareness attributes, just provide the attributes as a comma separated string in above setting e.g. 'zone,rack'. + You can either use `persistent` or `transient` settings. We recommend the `persistent` setting because it persists through a cluster reboot. Transient settings don't persist through a cluster reboot. Shard allocation awareness attempts to separate primary and replica shards across multiple zones. However, if only one zone is available (such as after a zone failure), OpenSearch allocates replica shards to the only remaining zone.