Elasticsearch cluster.routing.allocation.allow_rebalance Setting

Pulse - Elasticsearch Operations Done Right

On this page

Example Common Issues and Misuses Do's and Don'ts Frequently Asked Questions

The cluster.routing.allocation.allow_rebalance setting in Elasticsearch controls when shard rebalancing is allowed to occur within the cluster. This setting plays a crucial role in maintaining optimal shard distribution and cluster stability.

  • Default Value: indices_all_active
  • Possible Values:
    • always
    • indices_primary_active
    • indices_all_active

The cluster.routing.allocation.allow_rebalance setting determines the conditions under which Elasticsearch will attempt to rebalance shards across nodes in the cluster. The default value, indices_all_active, is generally the safest option as it ensures that rebalancing only occurs when all shards (both primary and replica) are active.

Example

To change the cluster.routing.allocation.allow_rebalance setting using the cluster settings API:

PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.allow_rebalance": "indices_primary_active"
  }
}

This change would allow rebalancing to occur as soon as all primary shards are active, without waiting for replica shards. This might be desirable in scenarios where you want to achieve faster rebalancing at the cost of potentially increased cluster instability.

Common Issues and Misuses

  • Setting this to always can lead to excessive shard movement during cluster changes, potentially impacting performance.
  • Using indices_primary_active might result in uneven shard distribution if replica shards fail to activate promptly.

Do's and Don'ts

  • Do keep the default setting unless you have a specific reason to change it.
  • Do monitor cluster stability and performance after changing this setting.
  • Don't set to always in production environments without careful consideration.
  • Don't change this setting frequently, as it can lead to unnecessary shard movements.

Frequently Asked Questions

Q: How does the cluster.routing.allocation.allow_rebalance setting affect cluster performance?
A: This setting can significantly impact cluster performance by controlling when shard rebalancing occurs. More frequent rebalancing (e.g., with always) can lead to increased network and disk I/O, potentially affecting query and indexing performance.

Q: Is it safe to change this setting in a production environment?
A: While it's possible to change this setting in production, it should be done cautiously. The default indices_all_active is generally the safest option. Any changes should be thoroughly tested in a staging environment first.

Q: How does this setting interact with other allocation settings?
A: This setting works in conjunction with other allocation settings like cluster.routing.allocation.enable and various shard allocation filters. It's important to consider the overall allocation strategy when adjusting this setting.

Q: Can this setting help in recovering from an unbalanced cluster state?
A: Yes, in some cases, temporarily changing this setting to indices_primary_active can help rebalance a cluster more quickly after node failures or additions. However, this should be done carefully and reverted once balance is restored.

Q: How often does Elasticsearch check this setting for rebalancing decisions?
A: Elasticsearch continuously monitors the cluster state and applies this setting during its regular rebalancing checks. The frequency of these checks can be influenced by other settings like cluster.routing.allocation.node_concurrent_recoveries.

Subscribe to the Pulse Newsletter

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