SolrCloud Autoscaling Automatically Adding Replicas

Solr provides a way to automatically add replicas for a collection when the number of active replicas drops below the replication factor specified at the time of the creation of the collection.

The autoAddReplicas Parameter

The boolean autoAddReplicas parameter can be passed to the CREATE command of the Collection API to enable this feature for a given collection.

Create a collection with autoAddReplicas enabled
http://localhost:8983/solr/admin/collections?action=CREATE&name=my_collection&numShards=1&replicationFactor=5&autoAddReplicas=true

The MODIFYCOLLECTION command can be used to enable/disable this feature for any collection.

Modify collection to disable autoAddReplicas
http://localhost:8983/solr/admin/collections?action=MODIFYCOLLECTION&name=my_collection&autoAddReplicas=false

Implementation Using .autoAddReplicas Trigger

A Trigger named .autoAddReplicas is automatically created whenever any collection has the autoAddReplicas feature enabled.

Only one trigger is sufficient to serve all collections having this feature enabled. The .autoAddReplicas trigger watches for nodes that are lost from the cluster and uses the default TriggerActions to create new replicas to replace the ones which were hosted by the lost node. If the old node comes back online, it unloads the moved replicas and the node is free to host other replicas as and when required.

Since the trigger provides the autoAddReplicas feature for all collections, the suspend-trigger and resume-trigger Autoscaling API commands can be used to disable and enable this feature for all collections in one API call.

Suspending autoAddReplicas for all collections
{
  "suspend-trigger": {
    "name" : ".autoAddReplicas"
  }
}
Resuming autoAddReplicas for all collections
{
  "resume-trigger": {
    "name" : ".autoAddReplicas"
  }
}

Using Cluster Property to Enable autoAddReplicas

A cluster property, also named autoAddReplicas, can be set to false to disable this feature for all collections. If this cluster property is missing or set to true, the autoAddReplicas is enabled for all collections.

Deprecation Warning

Using a cluster property to enable or disable autoAddReplicas is deprecated and only supported for back compatibility. Please use the suspend-trigger and resume-trigger API commands instead.