Skip to content

Commit

Permalink
Allocation awareness allocates some replicas
Browse files Browse the repository at this point in the history
The docs for forced awareness indicate that no replicas will be assigned
until all zones are available, which is definitely undesirable and also
not the actual behaviour. This commit fixes the wording to match what
really happens.

Closes elastic#104777
  • Loading branch information
DaveCTurner committed Jan 26, 2024
1 parent 85e4078 commit 7ffbd5c
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions docs/reference/modules/cluster/allocation_awareness.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,29 @@ enable forced awareness.
[[forced-awareness]]
===== Forced awareness

By default, if one location fails, Elasticsearch assigns all of the missing
replica shards to the remaining locations. While you might have sufficient
resources across all locations to host your primary and replica shards, a single
location might be unable to host *ALL* of the shards.
By default, if one location fails, {es} spreads its shards across the remaining
locations. This might be undesirable if the cluster does not have sufficient
resources to host all its shards when one location is missing.

To prevent a single location from being overloaded in the event of a failure,
you can set `cluster.routing.allocation.awareness.force` so no replicas are
allocated until nodes are available in another location.
To prevent the remaining locations from being overloaded in the event of a
whole-location failure, specify the attribute values that should exist with the
`cluster.routing.allocation.awareness.force.*` settings. This will mean that
{es} will prefer to leave some replicas unassigned in the event of a
whole-location failure instead of overloading the nodes in the remaining
locations.

For example, if you have an awareness attribute called `zone` and configure nodes
in `zone1` and `zone2`, you can use forced awareness to prevent Elasticsearch
from allocating replicas if only one zone is available:
For example, if you have an awareness attribute called `zone` and configure
nodes in `zone1` and `zone2`, you can use forced awareness to make {es} leave
half of your shard copies unassigned if only one zone is available:

[source,yaml]
-------------------------------------------------------------------
cluster.routing.allocation.awareness.attributes: zone
cluster.routing.allocation.awareness.force.zone.values: zone1,zone2 <1>
-------------------------------------------------------------------
<1> Specify all possible values for the awareness attribute.
<1> Specify all possible `zone` attribute values.

With this example configuration, if you start two nodes with `node.attr.zone` set
to `zone1` and create an index with 5 shards and 1 replica, Elasticsearch creates
the index and allocates the 5 primary shards but no replicas. Replicas are
only allocated once nodes with `node.attr.zone` set to `zone2` are available.
With this example configuration, if you start two nodes with `node.attr.zone`
set to `zone1` and create an index with 5 shards and 1 replica, {es} creates the
index and allocates the 5 primary shards but no replicas. Replicas are only
allocated once nodes with `node.attr.zone` set to `zone2` are available.

0 comments on commit 7ffbd5c

Please sign in to comment.