shards_allocation.asciidoc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. [[cluster-shard-allocation-settings]]
  2. ==== Cluster-level shard allocation settings
  3. You can use the following settings to control shard allocation and recovery:
  4. [[cluster-routing-allocation-enable]]
  5. `cluster.routing.allocation.enable`::
  6. +
  7. --
  8. (<<dynamic-cluster-setting,Dynamic>>)
  9. Enable or disable allocation for specific kinds of shards:
  10. * `all` - (default) Allows shard allocation for all kinds of shards.
  11. * `primaries` - Allows shard allocation only for primary shards.
  12. * `new_primaries` - Allows shard allocation only for primary shards for new indices.
  13. * `none` - No shard allocations of any kind are allowed for any indices.
  14. This setting does not affect the recovery of local primary shards when
  15. restarting a node. A restarted node that has a copy of an unassigned primary
  16. shard will recover that primary immediately, assuming that its allocation id matches
  17. one of the active allocation ids in the cluster state.
  18. --
  19. [[cluster-routing-allocation-same-shard-host]]
  20. `cluster.routing.allocation.same_shard.host`::
  21. (<<dynamic-cluster-setting,Dynamic>>)
  22. If `true`, forbids multiple copies of a shard from being allocated to
  23. distinct nodes on the same host, i.e. which have the same network
  24. address. Defaults to `false`, meaning that copies of a shard may
  25. sometimes be allocated to nodes on the same host. This setting is only
  26. relevant if you run multiple nodes on each host.
  27. `cluster.routing.allocation.node_concurrent_incoming_recoveries`::
  28. (<<dynamic-cluster-setting,Dynamic>>)
  29. How many concurrent incoming shard recoveries are allowed to happen on a
  30. node. Incoming recoveries are the recoveries where the target shard (most
  31. likely the replica unless a shard is relocating) is allocated on the node.
  32. Defaults to `2`. Increasing this setting may cause shard movements to have
  33. a performance impact on other activity in your cluster, but may not make
  34. shard movements complete noticeably sooner. We do not recommend adjusting
  35. this setting from its default of `2`.
  36. `cluster.routing.allocation.node_concurrent_outgoing_recoveries`::
  37. (<<dynamic-cluster-setting,Dynamic>>)
  38. How many concurrent outgoing shard recoveries are allowed to happen on a
  39. node. Outgoing recoveries are the recoveries where the source shard (most
  40. likely the primary unless a shard is relocating) is allocated on the node.
  41. Defaults to `2`. Increasing this setting may cause shard movements to have
  42. a performance impact on other activity in your cluster, but may not make
  43. shard movements complete noticeably sooner. We do not recommend adjusting
  44. this setting from its default of `2`.
  45. `cluster.routing.allocation.node_concurrent_recoveries`::
  46. (<<dynamic-cluster-setting,Dynamic>>)
  47. A shortcut to set both
  48. `cluster.routing.allocation.node_concurrent_incoming_recoveries` and
  49. `cluster.routing.allocation.node_concurrent_outgoing_recoveries`. The
  50. value of this setting takes effect only when the more specific setting is
  51. not configured. Defaults to `2`. Increasing this setting may cause shard
  52. movements to have a performance impact on other activity in your cluster,
  53. but may not make shard movements complete noticeably sooner. We do not
  54. recommend adjusting this setting from its default of `2`.
  55. `cluster.routing.allocation.node_initial_primaries_recoveries`::
  56. (<<dynamic-cluster-setting,Dynamic>>)
  57. While the recovery of replicas happens over the network, the recovery of
  58. an unassigned primary after node restart uses data from the local disk.
  59. These should be fast so more initial primary recoveries can happen in
  60. parallel on each node. Defaults to `4`. Increasing this setting may cause
  61. shard recoveries to have a performance impact on other activity in your
  62. cluster, but may not make shard recoveries complete noticeably sooner. We
  63. do not recommend adjusting this setting from its default of `4`.
  64. [[shards-rebalancing-settings]]
  65. ==== Shard rebalancing settings
  66. A cluster is _balanced_ when it has an equal number of shards on each node, with
  67. all nodes needing equal resources, without having a concentration of shards from
  68. any index on any node. {es} runs an automatic process called _rebalancing_ which
  69. moves shards between the nodes in your cluster to improve its balance.
  70. Rebalancing obeys all other shard allocation rules such as
  71. <<cluster-shard-allocation-filtering,allocation filtering>> and
  72. <<forced-awareness,forced awareness>> which may prevent it from completely
  73. balancing the cluster. In that case, rebalancing strives to achieve the most
  74. balanced cluster possible within the rules you have configured. If you are using
  75. <<data-tiers,data tiers>> then {es} automatically applies allocation filtering
  76. rules to place each shard within the appropriate tier. These rules mean that the
  77. balancer works independently within each tier.
  78. You can use the following settings to control the rebalancing of shards across
  79. the cluster:
  80. `cluster.routing.allocation.allow_rebalance`::
  81. +
  82. --
  83. (<<dynamic-cluster-setting,Dynamic>>)
  84. Specify when shard rebalancing is allowed:
  85. * `always` - Always allow rebalancing.
  86. * `indices_primaries_active` - Only when all primaries in the cluster are allocated.
  87. * `indices_all_active` - (default) Only when all shards (primaries and replicas) in the cluster are allocated.
  88. --
  89. `cluster.routing.rebalance.enable`::
  90. +
  91. --
  92. (<<dynamic-cluster-setting,Dynamic>>)
  93. Enable or disable rebalancing for specific kinds of shards:
  94. * `all` - (default) Allows shard balancing for all kinds of shards.
  95. * `primaries` - Allows shard balancing only for primary shards.
  96. * `replicas` - Allows shard balancing only for replica shards.
  97. * `none` - No shard balancing of any kind are allowed for any indices.
  98. Rebalancing is important to ensure the cluster returns to a healthy and fully
  99. resilient state after a disruption. If you adjust this setting, remember to set
  100. it back to `all` as soon as possible.
  101. --
  102. `cluster.routing.allocation.cluster_concurrent_rebalance`::
  103. (<<dynamic-cluster-setting,Dynamic>>)
  104. Defines the number of concurrent shard rebalances are allowed across the whole
  105. cluster. Defaults to `2`. Note that this setting only controls the number of
  106. concurrent shard relocations due to imbalances in the cluster. This setting
  107. does not limit shard relocations due to
  108. <<cluster-shard-allocation-filtering,allocation filtering>> or
  109. <<forced-awareness,forced awareness>>. Increasing this setting may cause the
  110. cluster to use additional resources moving shards between nodes, so we
  111. generally do not recommend adjusting this setting from its default of `2`.
  112. `cluster.routing.allocation.type`::
  113. +
  114. --
  115. Selects the algorithm used for computing the cluster balance. Defaults to
  116. `desired_balance` which selects the _desired balance allocator_. This allocator
  117. runs a background task which computes the desired balance of shards in the
  118. cluster. Once this background task completes, {es} moves shards to their
  119. desired locations.
  120. deprecated:[8.8,The `balanced` allocator type is deprecated and no longer recommended]
  121. May also be set to `balanced` to select the legacy _balanced allocator_. This
  122. allocator was the default allocator in versions of {es} before 8.6.0. It runs
  123. in the foreground, preventing the master from doing other work in parallel. It
  124. works by selecting a small number of shard movements which immediately improve
  125. the balance of the cluster, and when those shard movements complete it runs
  126. again and selects another few shards to move. Since this allocator makes its
  127. decisions based only on the current state of the cluster, it will sometimes
  128. move a shard several times while balancing the cluster.
  129. --
  130. [[shards-rebalancing-heuristics]]
  131. ==== Shard balancing heuristics settings
  132. Rebalancing works by computing a _weight_ for each node based on its allocation
  133. of shards, and then moving shards between nodes to reduce the weight of the
  134. heavier nodes and increase the weight of the lighter ones. The cluster is
  135. balanced when there is no possible shard movement that can bring the weight of
  136. any node closer to the weight of any other node by more than a configurable
  137. threshold.
  138. The weight of a node depends on the number of shards it holds and on the total
  139. estimated resource usage of those shards expressed in terms of the size of the
  140. shard on disk and the number of threads needed to support write traffic to the
  141. shard. {es} estimates the resource usage of shards belonging to data streams
  142. when they are created by a rollover. The estimated disk size of the new shard
  143. is the mean size of the other shards in the data stream. The estimated write
  144. load of the new shard is a weighted average of the actual write loads of recent
  145. shards in the data stream. Shards that do not belong to the write index of a
  146. data stream have an estimated write load of zero.
  147. The following settings control how {es} combines these values into an overall
  148. measure of each node's weight.
  149. `cluster.routing.allocation.balance.threshold`::
  150. (float, <<dynamic-cluster-setting,Dynamic>>)
  151. The minimum improvement in weight which triggers a rebalancing shard movement.
  152. Defaults to `1.0f`. Raising this value will cause {es} to stop rebalancing
  153. shards sooner, leaving the cluster in a more unbalanced state.
  154. `cluster.routing.allocation.balance.shard`::
  155. (float, <<dynamic-cluster-setting,Dynamic>>)
  156. Defines the weight factor for the total number of shards allocated to each node.
  157. Defaults to `0.45f`. Raising this value increases the tendency of {es} to
  158. equalize the total number of shards across nodes ahead of the other balancing
  159. variables.
  160. `cluster.routing.allocation.balance.index`::
  161. (float, <<dynamic-cluster-setting,Dynamic>>)
  162. Defines the weight factor for the number of shards per index allocated to each
  163. node. Defaults to `0.55f`. Raising this value increases the tendency of {es} to
  164. equalize the number of shards of each index across nodes ahead of the other
  165. balancing variables.
  166. `cluster.routing.allocation.balance.disk_usage`::
  167. (float, <<dynamic-cluster-setting,Dynamic>>)
  168. Defines the weight factor for balancing shards according to their predicted disk
  169. size in bytes. Defaults to `2e-11f`. Raising this value increases the tendency
  170. of {es} to equalize the total disk usage across nodes ahead of the other
  171. balancing variables.
  172. `cluster.routing.allocation.balance.write_load`::
  173. (float, <<dynamic-cluster-setting,Dynamic>>)
  174. Defines the weight factor for the write load of each shard, in terms of the
  175. estimated number of indexing threads needed by the shard. Defaults to `10.0f`.
  176. Raising this value increases the tendency of {es} to equalize the total write
  177. load across nodes ahead of the other balancing variables.
  178. [NOTE]
  179. ====
  180. * If you have a large cluster, it may be unnecessary to keep it in
  181. a perfectly balanced state at all times. It is less resource-intensive for the
  182. cluster to operate in a somewhat unbalanced state rather than to perform all
  183. the shard movements needed to achieve the perfect balance. If so, increase the
  184. value of `cluster.routing.allocation.balance.threshold` to define the
  185. acceptable imbalance between nodes. For instance, if you have an average of 500
  186. shards per node and can accept a difference of 5% (25 typical shards) between
  187. nodes, set `cluster.routing.allocation.balance.threshold` to `25`.
  188. * We do not recommend adjusting the values of the heuristic weight factor
  189. settings. The default values work well in all reasonable clusters. Although
  190. different values may improve the current balance in some ways, it is possible
  191. that they will create unexpected problems in the future or prevent it from
  192. gracefully handling an unexpected disruption.
  193. * Regardless of the result of the balancing algorithm, rebalancing might
  194. not be allowed due to allocation rules such as forced awareness and allocation
  195. filtering. Use the <<cluster-allocation-explain>> API to explain the current
  196. allocation of shards.
  197. ====