Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-6220

Replica placement strategy for solrcloud



    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.2, 6.0
    • Component/s: SolrCloud
    • Labels:



      Most cloud based systems allow to specify rules on how the replicas/nodes of a cluster are allocated . Solr should have a flexible mechanism through which we should be able to control allocation of replicas or later change it to suit the needs of the system

      All configurations are per collection basis. The rules are applied whenever a replica is created in any of the shards in a given collection during

      • collection creation
      • shard splitting
      • add replica
      • createsshard

      There are two aspects to how replicas are placed: snitch and placement.


      How to identify the tags of nodes. Snitches are configured through collection create command with the snitch param . eg: snitch=EC2Snitch or snitch=class:EC2Snitch


      This is shipped by default with Solr. user does not need to specify ImplicitSnitch in configuration. If the tags known to ImplicitSnitch are present in the rules , it is automatically used,
      tags provided by ImplicitSnitch

      1. cores : No:of cores in the node
      2. disk : Disk space available in the node
      3. host : host name of the node
      4. node: node name
      5. D.* : These are values available from systrem propertes. D.key means a value that is passed to the node as -Dkey=keyValue during the node startup. It is possible to use rules like D.key:expectedVal,shard:*


      This tells how many replicas for a given shard needs to be assigned to nodes with the given key value pairs. These parameters will be passed on to the collection CREATE api as a multivalued parameter "rule" . The values will be saved in the state of the collection as follows

        “snitch”: {
                   {"replica":"1" ,"shard" :"*" ,"node":"*"},

      A rule is specified as a pseudo JSON syntax . which is a map of keys and values
      *Each collection can have any number of rules. As long as the rules do not conflict with each other it should be OK. Or else an error is thrown

      • In each rule , shard and replica can be omitted
        • default value of replica is * means ANY or you can specify a count and an operand such as < (less than) or > (greater than)
        • and the value of shard can be a shard name or * means EACH or ** means ANY. default value is ** (ANY)
      • There should be exactly one extra condition in a rule other than shard and replica.
      • all keys other than shard and replica are called tags and the tags are nothing but values provided by the snitch for each node
      • By default certain tags such as node, host, port are provided by the system implicitly

      How are nodes picked up?

      Nodes are not picked up in random. The rules are used to first sort the nodes according to affinity. For example, if there is a rule that says disk:100+ , nodes with more disk space are given higher preference. And if the rule is disk:100- nodes with lesser disk space will be given priority. If everything else is equal , nodes with fewer cores are given higher priority

      Fuzzy match

      Fuzzy match can be applied when strict matches fail .The values can be prefixed ~ to specify fuzziness

      example rule

       #Example requirement "use only one replica of a shard in a host if possible, if no matches found , relax that rule". 
      #Another example, assign all replicas to nodes with disk space of 100GB or more,, or relax the rule if not possible. This will ensure that if a node does not exist with 100GB disk, nodes are picked up the order of size say a 85GB node would be picked up over 80GB disk node


      #in each rack there can be max two replicas of A given shard
      //in each rack there can be max two replicas of ANY replica
       #in each node there should be a max one replica of EACH shard
       #in each node there should be a max one replica of ANY shard
      #In rack 738 and shard=shard1, there can be a max 0 replica
       #All replicas of shard1 should go to rack 730
       #all replicas must be created in a node with at least 20GB disk
      #All replicas should be created in nodes with less than 5 cores
      #In this ANY AND each for shard have same meaning
      #one replica of shard1 must go to node
      node:””, shard:shard1, replica:1 
      #No replica of shard1 should go to rack 738
      #No replica  of ANY shard should go to rack 738

      In the collection create API all the placement rules are provided as a parameters called rule



        1. SOLR-6220.patch
          33 kB
          Noble Paul
        2. SOLR-6220.patch
          69 kB
          Noble Paul
        3. SOLR-6220.patch
          72 kB
          Noble Paul
        4. SOLR-6220.patch
          77 kB
          Noble Paul
        5. SOLR-6220.patch
          76 kB
          Noble Paul
        6. SOLR-6220.patch
          81 kB
          Noble Paul
        7. SOLR-6220.patch
          89 kB
          Noble Paul

          Issue Links



              • Assignee:
                noble.paul Noble Paul
                noble.paul Noble Paul
              • Votes:
                5 Vote for this issue
                23 Start watching this issue


                • Created: