2015-06-22 17:49:45 -04:00
[[circuit-breaker]]
2020-06-01 09:44:32 -04:00
=== Circuit breaker settings
2020-07-02 19:40:45 -04:00
[[circuit-breaker-description]]
// tag::circuit-breaker-description-tag[]
{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.
2015-06-22 17:49:45 -04:00
2019-07-31 07:13:39 -04:00
Except where noted otherwise, these settings can be dynamically updated on a
live cluster with the <<cluster-update-settings,cluster-update-settings>> API.
2020-07-02 19:40:45 -04:00
// end::circuit-breaker-description-tag[]
2015-06-22 17:49:45 -04:00
[[parent-circuit-breaker]]
2020-07-23 12:42:33 -04:00
[discrete]
2015-06-22 17:49:45 -04:00
==== Parent circuit breaker
2018-07-13 04:08:28 -04:00
The parent-level breaker can be configured with the following settings:
`indices.breaker.total.use_real_memory`::
2020-08-19 11:13:46 -04:00
(<<static-cluster-setting,Static>>)
Determines whether the parent breaker should take real
2019-07-31 07:13:39 -04:00
memory usage into account (`true`) or only consider the amount that is
reserved by child circuit breakers (`false`). Defaults to `true`.
2015-06-22 17:49:45 -04:00
2020-07-02 19:40:45 -04:00
[[indices-breaker-total-limit]]
// tag::indices-breaker-total-limit-tag[]
`indices.breaker.total.limit` {ess-icon}::
2020-08-19 11:13:46 -04:00
(<<dynamic-cluster-setting,Dynamic>>)
2020-07-02 19:40:45 -04:00
Starting limit for overall parent breaker. Defaults to 70% of JVM heap if
2018-07-13 04:08:28 -04:00
`indices.breaker.total.use_real_memory` is `false`. If `indices.breaker.total.use_real_memory`
is `true`, defaults to 95% of the JVM heap.
2020-07-02 19:40:45 -04:00
// end::indices-breaker-total-limit-tag[]
2015-06-22 17:49:45 -04:00
[[fielddata-circuit-breaker]]
2020-07-23 12:42:33 -04:00
[discrete]
2015-06-22 17:49:45 -04:00
==== Field data circuit breaker
The field data circuit breaker allows Elasticsearch to estimate the amount of
memory a field will require to be loaded into memory. It can then prevent the
field data loading by raising an exception. By default the limit is configured
2018-12-11 05:30:58 -05:00
to 40% of the maximum JVM heap. It can be configured with the following
2015-06-22 17:49:45 -04:00
parameters:
2020-07-02 19:40:45 -04:00
[[fielddata-circuit-breaker-limit]]
// tag::fielddata-circuit-breaker-limit-tag[]
`indices.breaker.fielddata.limit` {ess-icon}::
2020-08-19 11:13:46 -04:00
(<<dynamic-cluster-setting,Dynamic>>)
2020-07-02 19:40:45 -04:00
Limit for fielddata breaker. Defaults to 40% of JVM heap.
// end::fielddata-circuit-breaker-limit-tag[]
2015-06-22 17:49:45 -04:00
2020-07-02 19:40:45 -04:00
[[fielddata-circuit-breaker-overhead]]
// tag::fielddata-circuit-breaker-overhead-tag[]
`indices.breaker.fielddata.overhead` {ess-icon}::
2020-08-19 11:13:46 -04:00
(<<dynamic-cluster-setting,Dynamic>>)
2015-06-22 17:49:45 -04:00
A constant that all field data estimations are multiplied with to determine a
2020-07-02 19:40:45 -04:00
final estimation. Defaults to `1.03`.
// end::fielddata-circuit-breaker-overhead-tag[]
2015-06-22 17:49:45 -04:00
[[request-circuit-breaker]]
2020-07-23 12:42:33 -04:00
[discrete]
2015-06-22 17:49:45 -04:00
==== Request circuit breaker
The request circuit breaker allows Elasticsearch to prevent per-request data
structures (for example, memory used for calculating aggregations during a
request) from exceeding a certain amount of memory.
2020-07-02 19:40:45 -04:00
[[request-breaker-limit]]
// tag::request-breaker-limit-tag[]
`indices.breaker.request.limit` {ess-icon}::
2020-08-19 11:13:46 -04:00
(<<dynamic-cluster-setting,Dynamic>>)
2020-07-02 19:40:45 -04:00
Limit for request breaker, defaults to 60% of JVM heap.
// end::request-breaker-limit-tag[]
2015-06-22 17:49:45 -04:00
2020-07-02 19:40:45 -04:00
[[request-breaker-overhead]]
// tag::request-breaker-overhead-tag[]
`indices.breaker.request.overhead` {ess-icon}::
2020-08-19 11:13:46 -04:00
(<<dynamic-cluster-setting,Dynamic>>)
2015-06-22 17:49:45 -04:00
A constant that all request estimations are multiplied with to determine a
2020-07-02 19:40:45 -04:00
final estimation. Defaults to `1`.
// end::request-breaker-overhead-tag[]
2015-06-22 17:49:45 -04:00
2016-04-13 03:54:59 -04:00
[[in-flight-circuit-breaker]]
2020-07-23 12:42:33 -04:00
[discrete]
2016-04-13 03:54:59 -04:00
==== In flight requests circuit breaker
The in flight requests circuit breaker allows Elasticsearch to limit the memory usage of all
currently active incoming requests on transport or HTTP level from exceeding a certain amount of
2018-07-03 03:17:16 -04:00
memory on a node. The memory usage is based on the content length of the request itself. This
circuit breaker also considers that memory is not only needed for representing the raw request but
also as a structured object which is reflected by default overhead.
2016-04-13 03:54:59 -04:00
`network.breaker.inflight_requests.limit`::
2020-08-19 11:13:46 -04:00
(<<dynamic-cluster-setting,Dynamic>>)
2016-04-13 03:54:59 -04:00
Limit for in flight requests breaker, defaults to 100% of JVM heap. This means that it is bound
by the limit configured for the parent circuit breaker.
`network.breaker.inflight_requests.overhead`::
2020-08-19 11:13:46 -04:00
(<<dynamic-cluster-setting,Dynamic>>)
2016-04-13 03:54:59 -04:00
A constant that all in flight requests estimations are multiplied with to determine a
2018-07-03 03:17:16 -04:00
final estimation. Defaults to 2.
2016-04-13 03:54:59 -04:00
2017-12-01 09:59:45 -05:00
[[accounting-circuit-breaker]]
2020-07-23 12:42:33 -04:00
[discrete]
2017-12-01 09:59:45 -05:00
==== Accounting requests circuit breaker
2018-05-22 10:43:45 -04:00
The accounting circuit breaker allows Elasticsearch to limit the memory
2017-12-01 09:59:45 -05:00
usage of things held in memory that are not released when a request is
completed. This includes things like the Lucene segment memory.
2018-06-04 04:19:38 -04:00
`indices.breaker.accounting.limit`::
2020-08-19 11:13:46 -04:00
(<<dynamic-cluster-setting,Dynamic>>)
2017-12-01 09:59:45 -05:00
Limit for accounting breaker, defaults to 100% of JVM heap. This means that it is bound
by the limit configured for the parent circuit breaker.
2018-06-04 04:19:38 -04:00
`indices.breaker.accounting.overhead`::
2020-08-19 11:13:46 -04:00
(<<dynamic-cluster-setting,Dynamic>>)
2017-12-01 09:59:45 -05:00
A constant that all accounting estimations are multiplied with to determine a
final estimation. Defaults to 1
Circuit break the number of inline scripts compiled per minute
When compiling many dynamically changing scripts, parameterized
scripts (<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-using.html#prefer-params>)
should be preferred. This enforces a limit to the number of scripts that
can be compiled within a minute. A new dynamic setting is added -
`script.max_compilations_per_minute`, which defaults to 15.
If more dynamic scripts are sent, a user will get the following
exception:
```json
{
"error" : {
"root_cause" : [
{
"type" : "circuit_breaking_exception",
"reason" : "[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead",
"bytes_wanted" : 0,
"bytes_limit" : 0
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "i",
"node" : "a5V1eXcZRYiIk8lecjZ4Jw",
"reason" : {
"type" : "general_script_exception",
"reason" : "Failed to compile inline script [\"aaaaaaaaaaaaaaaa\"] using lang [painless]",
"caused_by" : {
"type" : "circuit_breaking_exception",
"reason" : "[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead",
"bytes_wanted" : 0,
"bytes_limit" : 0
}
}
}
],
"caused_by" : {
"type" : "general_script_exception",
"reason" : "Failed to compile inline script [\"aaaaaaaaaaaaaaaa\"] using lang [painless]",
"caused_by" : {
"type" : "circuit_breaking_exception",
"reason" : "[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead",
"bytes_wanted" : 0,
"bytes_limit" : 0
}
}
},
"status" : 500
}
```
This also fixes a bug in `ScriptService` where requests being executed
concurrently on a single node could cause a script to be compiled
multiple times (many in the case of a powerful node with many shards)
due to no synchronization between checking the cache and compiling the
script. There is now synchronization so that a script being compiled
will only be compiled once regardless of the number of concurrent
searches on a node.
Relates to #19396
2016-07-26 15:36:29 -04:00
[[script-compilation-circuit-breaker]]
2020-07-23 12:42:33 -04:00
[discrete]
Circuit break the number of inline scripts compiled per minute
When compiling many dynamically changing scripts, parameterized
scripts (<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-using.html#prefer-params>)
should be preferred. This enforces a limit to the number of scripts that
can be compiled within a minute. A new dynamic setting is added -
`script.max_compilations_per_minute`, which defaults to 15.
If more dynamic scripts are sent, a user will get the following
exception:
```json
{
"error" : {
"root_cause" : [
{
"type" : "circuit_breaking_exception",
"reason" : "[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead",
"bytes_wanted" : 0,
"bytes_limit" : 0
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "i",
"node" : "a5V1eXcZRYiIk8lecjZ4Jw",
"reason" : {
"type" : "general_script_exception",
"reason" : "Failed to compile inline script [\"aaaaaaaaaaaaaaaa\"] using lang [painless]",
"caused_by" : {
"type" : "circuit_breaking_exception",
"reason" : "[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead",
"bytes_wanted" : 0,
"bytes_limit" : 0
}
}
}
],
"caused_by" : {
"type" : "general_script_exception",
"reason" : "Failed to compile inline script [\"aaaaaaaaaaaaaaaa\"] using lang [painless]",
"caused_by" : {
"type" : "circuit_breaking_exception",
"reason" : "[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead",
"bytes_wanted" : 0,
"bytes_limit" : 0
}
}
},
"status" : 500
}
```
This also fixes a bug in `ScriptService` where requests being executed
concurrently on a single node could cause a script to be compiled
multiple times (many in the case of a powerful node with many shards)
due to no synchronization between checking the cache and compiling the
script. There is now synchronization so that a script being compiled
will only be compiled once regardless of the number of concurrent
searches on a node.
Relates to #19396
2016-07-26 15:36:29 -04:00
==== Script compilation circuit breaker
Slightly different than the previous memory-based circuit breaker, the script
compilation circuit breaker limits the number of inline script compilations
within a period of time.
See the "prefer-parameters" section of the <<modules-scripting-using,scripting>>
documentation for more information.
2020-06-18 13:54:23 -04:00
`script.context.$CONTEXT.max_compilations_rate`::
2020-08-19 11:13:46 -04:00
(<<dynamic-cluster-setting,Dynamic>>)
2017-09-01 04:15:27 -04:00
Limit for the number of unique dynamic scripts within a certain interval
2020-06-18 13:54:23 -04:00
that are allowed to be compiled for a given context. Defaults to `75/5m`,
meaning 75 every 5 minutes.