Elasticsearch Recovery

By Opster Team

Updated: Oct 9, 2023

| 3 min read


In Elasticsearch, recovery refers to the process of recovering a shard when something goes wrong. Shard recoveries can take place in various circumstances, such as when a node fails and a replica shard needs to be recreated from a primary shard, when the cluster needs to relocate shards to different nodes due to a rebalancing or a change in shard allocation settings, or when restoring an index from an Elasticsearch snapshot. Alternatively, Elasticsearch can sometimes perform recoveries automatically, such as when a node restarts or disconnects and connects again. In summary, recovery can happen in the following scenarios:

  • Node startup or failure (local store recovery)
  • Replication of primary shards to replica shards
  • Relocation of a shard to a different node in the same cluster
  • Restoration of a snapshot

Planned node restart

If you are planning to restart a node, there are some actions that you can take to speed up the shard recoveries when the node has restarted. For optimal recovery speed, you should stop any indexing to the shards that are hosted on the node that is about to be restarted. Once you’ve stopped your indexing process, you can perform the following actions:

1. Disable shard allocation to prevent shards from being reallocated to other nodes while the node is restarting using the following command:

PUT _cluster/settings
  "persistent": {
    "cluster.routing.allocation.enable": "primaries"

It is worth noting that by default the shard relocation process only starts after one minute and that delay can be configured with the `index.unassigned.node_left.delayed_timeout` index setting.

2. Once shard relocation is disabled, you need to flush the transaction logs (using the command below), which will ensure that all operations currently stored in the transactions log are safely committed to the Lucene index on disk. That will save you time during the restart since no operations will need to be replayed, meaning that the recovery of your shards will be faster.

POST /_flush

Note that prior to ES 8.0, this operation was called synced-flush, but it was deprecated in 7.6 and removed in 8.0.

3. At this point, you can restart your node.

4. When the node has properly restarted, you can re-enable shard allocation using the following command:

PUT _cluster/settings
  "persistent": {
    "cluster.routing.allocation.enable": null

If you have several nodes to restart or you are performing a full cluster restart, you can use the same procedure. The key points to remember for speeding up the recovery process are to stop any indexing and to flush your transaction log.

While the recovery process is in progress, there are a few API calls that allow us to monitor the status of the shard recoveries:

# Check the recovery status of a specific index

GET /<index>/_recovery

# Check the recovery status of all indexes

GET /_recovery

# Check the recovery status of all indexes (more concise format)

GET _cat/recovery

Tweaking recovery speed

If you cannot stop your indexing process for whatever reason, you can still perform the same procedure. However, since new data will keep flowing in while the node is restarting, all the indexing operations will need to be replayed, which will slow down the recovery process. However, there are a few knobs that you can tune to speed this up provided you have sufficient hardware resources (CPU, RAM, network).

By default, the total inbound and outbound recovery traffic on each hot and warm data node is limited to 40 Mbps. For dedicated cold and frozen nodes, that limit ranges from 40 Mbps to 250 Mbps depending on the total amount of memory available on those nodes. These default values have been determined empirically based on the assumption that the hardware is composed of standard SSD disks and a network interface with 1 Gbps throughput.If you have superior hardware (e.g., 10 Gbps network and 100K IOPS disks), you can increase the recovery traffic limit to a higher value using the following command:

PUT /_cluster/settings
   "transient": {
      "indices.recovery.max_bytes_per_sec": "100mb"

You should be very careful when changing this setting as it can harm your cluster performance if the value you set is too high. Also, there are a few other expert settings that you can tweak if you want to optimize the recovery process, but changing the defaults on these expert settings is strongly discouraged unless you know exactly what you’re doing.


In this guide, we have explained what the shard recovery process is and under which circumstances it kicks in. We have also reviewed a few techniques to speed up the recovery process and highlighted what you need to pay attention to when you start tweaking the default recovery settings values.

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Related log errors to this ES concept

Error while listing local files resetting the starting sequence number from
Exception while closing %s
Unexpected error while monitoring recovery recoveryId
Unexpected error while preparing shard for peer recovery failing recovery
Unexpected error during recovery recoveryId failing shard
Unexpected error during recovery but recovery id recoveryId is finished
Error while closing recovery output entry getValue
Unable to fetch shard snapshot files for %s
Failed to invoke the listener before the shard recovery starts for %s
Unable to fetch available snapshots for shard %s
Delaying recovery of for due to networking error
Error while closing recovery output

< Page: 2 of 7 >