Elasticsearch Circuit

Elasticsearch Circuit

Last Update: March 2020

Before you start reading this page, try the new Elasticsearch Check-Up - Get actionable recommendations that can improve your cluster search and indexing speed (no installation required).

Circuit 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 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.

About Opster

Opster is redefining Elasticsearch management - pro-actively troubleshooting, optimizing performance, operating on clusters and assisting with all things needed to successfully run ES in production


Click below to learn how to fix common problems related to these concepts
« Back to Index