Elasticsearch tips: auto_expand_replicas

Elasticsearch tips: auto_expand_replicas

๐Ÿ“… Published: โ€ข Thomas Queste

The auto_expand_replicas setting in Elasticsearch dynamically adjust replica counts during cluster scaling.

TL;DR

  • The auto_expand_replicas setting automatically adjusts replica count when nodes change
  • Eliminates manual replica management during cluster scaling
  • Set to 0-all for replicas on all available data nodes
  • Use custom ranges like 0-2 for controlled replication

How we use it

Auto-expand replicas solves this by dynamically adjusting replicas based on cluster size.

โญ We use this in our performance environment after scaling operations to get the appropriate number of replicas.

Because it happened, we forgot to increase the number of replicas after scaling up the cluster! ๐Ÿ˜ซ

Typical Usage

PUT my_index
{
  "settings": {
    "auto_expand_replicas": "0-all"
  }
}

Improve this post

Previous post: Elasticsearch best practice: disable dynamic mapping
Next post: Elasticsearch 101: Object vs Nested