Elasticsearch Circuit Breakers


Elasticsearch Circuit Breakers

Opster Team

Nov 2020


In addition to reading this guide, run the free Elasticsearch Health Check-Up. Get actionable recommendations that can improve performance and prevent incidents (does not require any installation). Among the dozens of checks included are: shards sizes, search errors, thread pools, management queue size, circuit breakers and many more. Join over 700 users who use this free tool.

Breakers in Elasticsearch

What it is:

Circuit breakers are used to prevent operations from causing an OutOfMemoryError in Elasticsearch. There are many settings related to circuit breakers, and each of those settings can be configured using the cluster update API.

There are many types of circuit breakers, such as parent level circuit breakers, request circuit breakers, field data circuit breakers, script compilation circuit breakers and more. All of these put default limits on the amount of memory/heap size that can be used or set a limit on the rate of some other operations that can be done.

Examples:

Limit the amount of memory used by fielddata to use up to 30% of JVM heap:

PUT /_cluster/settings
{
    "persistent" : {
           “indices.breaker.fielddata.limit”: “30%”
    }
}

Putting a limit on the number of dynamic scripts to be compiled in 5 minutes:

PUT /_cluster/settings
{
    "persistent" : {
        “script.max_compilations_rate” : “50/5m”
}
}

Notes and good things to know:

  • Script.max_compilations_rate limits the number of scripts that can be compiled in a given time interval, the default is 75 per 5 minutes. If you compile too many unique scripts within a small amount of time, Elasticsearch will reject the new dynamic scripts and throw a circuit_breaking_exception error.

Common problems:

  • In production environments you need to limit the amount of heap size used by memory intensive search queries by setting indices.breaker.request.limit to a lower value such as 40%, otherwise this will crash Elasticsearch nodes if the settings are left unbounded or above 70%.
  • Similarly, the nodes can also crash if other circuit breaker limits are not properly configured.
  • In addition, apart from circuit breakers, you will need to limit the number of max search buckets for aggregations as well.




Improve Elasticsearch Performance

Run The Analysis