circuit_breaker.asciidoc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. [[circuit-breaker]]
  2. === Circuit breaker settings
  3. [[circuit-breaker-description]]
  4. // tag::circuit-breaker-description-tag[]
  5. {es} contains multiple circuit breakers used to prevent operations from causing an OutOfMemoryError. Each breaker specifies a limit for how much memory it can use. Additionally, there is a parent-level breaker that specifies the total amount of memory that can be used across all breakers.
  6. Except where noted otherwise, these settings can be dynamically updated on a
  7. live cluster with the <<cluster-update-settings,cluster-update-settings>> API.
  8. // end::circuit-breaker-description-tag[]
  9. For information about circuit breaker errors, see <<circuit-breaker-errors>>.
  10. [[parent-circuit-breaker]]
  11. [discrete]
  12. ==== Parent circuit breaker
  13. The parent-level breaker can be configured with the following settings:
  14. `indices.breaker.total.use_real_memory`::
  15. (<<static-cluster-setting,Static>>)
  16. Determines whether the parent breaker should take real
  17. memory usage into account (`true`) or only consider the amount that is
  18. reserved by child circuit breakers (`false`). Defaults to `true`.
  19. [[indices-breaker-total-limit]]
  20. // tag::indices-breaker-total-limit-tag[]
  21. `indices.breaker.total.limit` {ess-icon}::
  22. (<<dynamic-cluster-setting,Dynamic>>)
  23. Starting limit for overall parent breaker. Defaults to 70% of JVM heap if
  24. `indices.breaker.total.use_real_memory` is `false`. If `indices.breaker.total.use_real_memory`
  25. is `true`, defaults to 95% of the JVM heap.
  26. // end::indices-breaker-total-limit-tag[]
  27. [[fielddata-circuit-breaker]]
  28. [discrete]
  29. ==== Field data circuit breaker
  30. The field data circuit breaker estimates the heap memory required to load a
  31. field into the <<modules-fielddata,field data cache>>. If loading the field would
  32. cause the cache to exceed a predefined memory limit, the circuit breaker stops the
  33. operation and returns an error.
  34. [[fielddata-circuit-breaker-limit]]
  35. // tag::fielddata-circuit-breaker-limit-tag[]
  36. `indices.breaker.fielddata.limit` {ess-icon}::
  37. (<<dynamic-cluster-setting,Dynamic>>)
  38. Limit for fielddata breaker. Defaults to 40% of JVM heap.
  39. // end::fielddata-circuit-breaker-limit-tag[]
  40. [[fielddata-circuit-breaker-overhead]]
  41. // tag::fielddata-circuit-breaker-overhead-tag[]
  42. `indices.breaker.fielddata.overhead` {ess-icon}::
  43. (<<dynamic-cluster-setting,Dynamic>>)
  44. A constant that all field data estimations are multiplied with to determine a
  45. final estimation. Defaults to `1.03`.
  46. // end::fielddata-circuit-breaker-overhead-tag[]
  47. [[request-circuit-breaker]]
  48. [discrete]
  49. ==== Request circuit breaker
  50. The request circuit breaker allows Elasticsearch to prevent per-request data
  51. structures (for example, memory used for calculating aggregations during a
  52. request) from exceeding a certain amount of memory.
  53. [[request-breaker-limit]]
  54. // tag::request-breaker-limit-tag[]
  55. `indices.breaker.request.limit` {ess-icon}::
  56. (<<dynamic-cluster-setting,Dynamic>>)
  57. Limit for request breaker, defaults to 60% of JVM heap.
  58. // end::request-breaker-limit-tag[]
  59. [[request-breaker-overhead]]
  60. // tag::request-breaker-overhead-tag[]
  61. `indices.breaker.request.overhead` {ess-icon}::
  62. (<<dynamic-cluster-setting,Dynamic>>)
  63. A constant that all request estimations are multiplied with to determine a
  64. final estimation. Defaults to `1`.
  65. // end::request-breaker-overhead-tag[]
  66. [[in-flight-circuit-breaker]]
  67. [discrete]
  68. ==== In flight requests circuit breaker
  69. The in flight requests circuit breaker allows Elasticsearch to limit the memory usage of all
  70. currently active incoming requests on transport or HTTP level from exceeding a certain amount of
  71. memory on a node. The memory usage is based on the content length of the request itself. This
  72. circuit breaker also considers that memory is not only needed for representing the raw request but
  73. also as a structured object which is reflected by default overhead.
  74. `network.breaker.inflight_requests.limit`::
  75. (<<dynamic-cluster-setting,Dynamic>>)
  76. Limit for in flight requests breaker, defaults to 100% of JVM heap. This means that it is bound
  77. by the limit configured for the parent circuit breaker.
  78. `network.breaker.inflight_requests.overhead`::
  79. (<<dynamic-cluster-setting,Dynamic>>)
  80. A constant that all in flight requests estimations are multiplied with to determine a
  81. final estimation. Defaults to 2.
  82. [[accounting-circuit-breaker]]
  83. [discrete]
  84. ==== Accounting requests circuit breaker
  85. The accounting circuit breaker allows Elasticsearch to limit the memory
  86. usage of things held in memory that are not released when a request is
  87. completed. This includes things like the Lucene segment memory.
  88. `indices.breaker.accounting.limit`::
  89. (<<dynamic-cluster-setting,Dynamic>>)
  90. Limit for accounting breaker, defaults to 100% of JVM heap. This means that it is bound
  91. by the limit configured for the parent circuit breaker.
  92. `indices.breaker.accounting.overhead`::
  93. (<<dynamic-cluster-setting,Dynamic>>)
  94. A constant that all accounting estimations are multiplied with to determine a
  95. final estimation. Defaults to 1
  96. [[script-compilation-circuit-breaker]]
  97. [discrete]
  98. ==== Script compilation circuit breaker
  99. Slightly different than the previous memory-based circuit breaker, the script
  100. compilation circuit breaker limits the number of inline script compilations
  101. within a period of time.
  102. See the "prefer-parameters" section of the <<modules-scripting-using,scripting>>
  103. documentation for more information.
  104. `script.max_compilations_rate`::
  105. (<<dynamic-cluster-setting,Dynamic>>)
  106. Limit for the number of unique dynamic scripts within a certain interval
  107. that are allowed to be compiled. Defaults to `150/5m`,
  108. meaning 150 every 5 minutes.
  109. If the cluster regularly hits the given `max_compilation_rate`, it's possible the
  110. script cache is undersized, use <<cluster-nodes-stats,Nodes Stats>> to inspect
  111. the number of recent cache evictions, `script.cache_evictions_history` and
  112. compilations `script.compilations_history`. If there are a large
  113. number of recent cache evictions or compilations, the script cache may be
  114. undersized, consider doubling the size of the script cache via the setting
  115. `script.cache.max_size`.
  116. [[regex-circuit-breaker]]
  117. [discrete]
  118. ==== Regex circuit breaker
  119. Poorly written regular expressions can degrade cluster stability and
  120. performance. The regex circuit breaker limits the use and complexity of
  121. {painless}/painless-regexes.html[regex in Painless scripts].
  122. [[script-painless-regex-enabled]]
  123. `script.painless.regex.enabled`::
  124. (<<static-cluster-setting,Static>>) Enables regex in Painless scripts. Accepts:
  125. `limited` (Default):::
  126. Enables regex but limits complexity using the
  127. <<script-painless-regex-limit-factor,`script.painless.regex.limit-factor`>>
  128. cluster setting.
  129. `true`:::
  130. Enables regex with no complexity limits. Disables the regex circuit breaker.
  131. `false`:::
  132. Disables regex. Any Painless script containing a regular expression returns an
  133. error.
  134. [[script-painless-regex-limit-factor]]
  135. `script.painless.regex.limit-factor`::
  136. (<<static-cluster-setting,Static>>) Limits the number of characters a regular
  137. expression in a Painless script can consider. {es} calculates this limit by
  138. multiplying the setting value by the script input's character length.
  139. +
  140. For example, the input `foobarbaz` has a character length of `9`. If
  141. `script.painless.regex.limit-factor` is `6`, a regular expression on `foobarbaz`
  142. can consider up to 54 (9 * 6) characters. If the expression exceeds this limit,
  143. it triggers the regex circuit breaker and returns an error.
  144. +
  145. {es} only applies this limit if
  146. <<script-painless-regex-enabled,`script.painless.regex.enabled`>> is `limited`.
  147. [[circuit-breakers-page-eql]]
  148. [discrete]
  149. === EQL circuit breaker
  150. When a <<eql-sequences, sequence>> query is executed, the node handling the query
  151. needs to keep some structures in memory, which are needed by the algorithm
  152. implementing the sequence matching. When large amounts of data need to be processed,
  153. and/or a large amount of matched sequences is requested by the user (by setting the
  154. <<eql-search-api-params-size, size>> query param), the memory occupied by those
  155. structures could potentially exceed the available memory of the JVM. This would cause
  156. an `OutOfMemory` exception which would bring down the node.
  157. To prevent this from happening, a special <<circuit-breaker, circuit breaker>> is used,
  158. which limits the memory allocation during the execution of a <<eql-sequences, sequence>>
  159. query. When the breaker is triggered, an `org.elasticsearch.common.breaker.CircuitBreakingException`
  160. is thrown and a descriptive error message is returned to the user.
  161. This <<circuit-breaker, circuit breaker>> can be configured using the following settings:
  162. `breaker.eql_sequence.limit`::
  163. (<<cluster-update-settings,Dynamic>>) The limit for circuit breaker used to restrict
  164. the memory utilisation during the execution of an EQL sequence query. This value is
  165. defined as a percentage of the JVM heap. Defaults to `50%`. If the
  166. <<parent-circuit-breaker,parent circuit breaker>> is set to a value less than `50%`,
  167. this setting uses that value as its default instead.
  168. `breaker.eql_sequence.overhead`::
  169. (<<cluster-update-settings,Dynamic>>) A constant that sequence query memory
  170. estimates are multiplied by to determine a final estimate. Defaults to `1`.
  171. `breaker.eql_sequence.type`::
  172. (<<static-cluster-setting,Static>>) Circuit breaker type. Valid values are:
  173. `memory` (Default):::
  174. The breaker limits memory usage for EQL sequence queries.
  175. `noop`:::
  176. Disables the breaker.
  177. [[circuit-breakers-page-model-inference]]
  178. [discrete]
  179. ==== {ml-cap} circuit breaker
  180. `breaker.model_inference.limit`::
  181. (<<cluster-update-settings,Dynamic>>) The limit for the trained model circuit
  182. breaker. This value is defined as a percentage of the JVM heap. Defaults to
  183. `50%`. If the <<parent-circuit-breaker,parent circuit breaker>> is set to a
  184. value less than `50%`, this setting uses that value as its default instead.
  185. `breaker.model_inference.overhead`::
  186. (<<cluster-update-settings,Dynamic>>) A constant that all trained model
  187. estimations are multiplied by to determine a final estimation. See
  188. <<circuit-breaker>>. Defaults to `1`.
  189. `breaker.model_inference.type`::
  190. (<<static-cluster-setting,Static>>) The underlying type of the circuit breaker.
  191. There are two valid options: `noop` and `memory`. `noop` means the circuit
  192. breaker does nothing to prevent too much memory usage. `memory` means the
  193. circuit breaker tracks the memory used by trained models and can potentially
  194. break and prevent `OutOfMemory` errors. The default value is `memory`.