Elasticsearch cluster.routing.allocation.awareness.attributes Setting

The cluster.routing.allocation.awareness.attributes setting in Elasticsearch controls shard allocation based on node attributes. It allows you to define attributes that Elasticsearch should consider when distributing shards across nodes, ensuring better distribution and fault tolerance.

  • Default value: Not set
  • Possible values: A comma-separated list of attribute names
  • Recommendations: Use this setting when you have nodes spread across different availability zones, racks, or data centers to improve fault tolerance and data locality.

This setting works in conjunction with node attributes that you define. When set, Elasticsearch tries to allocate primary and replica shards on nodes with different values for the specified attributes, improving the cluster's resilience to failures.

Example

To enable awareness for zone and rack attributes:

cluster.routing.allocation.awareness.attributes: zone,rack

You would then set these attributes on your nodes:

node.attr.zone: zone1
node.attr.rack: rack1

This configuration helps Elasticsearch distribute shards across different zones and racks, reducing the risk of data loss if a entire zone or rack fails.

Common Issues and Misuses

  • Overusing awareness attributes can lead to unbalanced shard allocation if node distribution is not even across attribute values.
  • Forgetting to set the corresponding node attributes will render the awareness setting ineffective.
  • Using too many awareness attributes can complicate shard allocation and potentially impact performance.

Do's and Don'ts

Do's:

  • Use awareness attributes for significant infrastructure divisions (e.g., availability zones, data centers).
  • Ensure an even distribution of nodes across attribute values.
  • Monitor shard allocation to verify the effectiveness of your configuration.

Don'ts:

  • Don't use awareness for minor or frequently changing node characteristics.
  • Avoid setting too many awareness attributes, as it can complicate allocation decisions.
  • Don't forget to set the corresponding attributes on your nodes.

Frequently Asked Questions

Q: How many awareness attributes can I set?
A: While there's no hard limit, it's recommended to use no more than two or three attributes to keep allocation logic manageable and effective.

Q: Does this setting affect existing shard allocations?
A: Changing this setting will not immediately reallocate existing shards. It will affect new allocations and can trigger rebalancing over time.

Q: Can I use this setting in a single-zone deployment?
A: While possible, it's less beneficial. This setting is most effective when nodes are distributed across multiple physical or logical divisions.

Q: How does this setting interact with forced awareness?
A: Forced awareness (set via cluster.routing.allocation.awareness.force.*) works in conjunction with this setting to ensure replicas are always allocated to different awareness attribute values.

Q: Can awareness attributes be changed dynamically?
A: The cluster.routing.allocation.awareness.attributes setting can be updated dynamically, but changes to node attributes typically require a node restart to take effect.

Pulse - Elasticsearch Operations Done Right

Stop googling errors and staring at dashboards.

Free Trial

Subscribe to the Pulse Newsletter

Get early access to new Pulse features, insightful blogs & exclusive events , webinars, and workshops.