# Circuit Breaker Exception

**URL:** <https://discuss.elastic.co/t/circuit-breaker-exception/293737>\
**Category:** Elasticsearch\
**Created:** [January 7, 2022, 12:32pm UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737 "2022-01-07T12:32:11Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suresh\_Ghatuwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suresh_ghatuwa/32/99976_2.png) [@Suresh\_Ghatuwa](https://discuss.elastic.co/u/Suresh_Ghatuwa)\
**Post date:** [January 7, 2022, 12:32pm UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737/1 "2022-01-07T12:32:11Z")

</div>

I am working on ES Circuit Breaker implementation. I got circuit breaker exception if heavy terms aggregation. But if multiple es query with less JVM usage than limit is executed, then we got Out Of Memory exception.

**Question:**

- Suppose if JVM is 450 and set 40% as limit (i.e. 180 MB), does circuit breaker check if executed query exceed 180MB ?
- If we run multiples query that require 160MB each. (i.e. executing 5 6 queries parallerly) Do we get still an circuit breaker?

**Circuit Breaker Setting in Elasticsearch.yml:**  
indices.breaker.total.use\_real\_memory: false  
indices.breaker.total.limit: "40%"  
indices.breaker.request.limit: "40%"  
indices.breaker.request.overhead: 2  
indices.breaker.accounting.limit: "40%"  
indices.breaker.accounting.overhead: 2  
network.breaker.inflight\_requests.limit: "40%"  
network.breaker.inflight\_requests.overhead: 2  
indices.breaker.fielddata.limit: "40%"  
indices.breaker.fielddata.overhead: 2  
indices.breaker.fielddata.type: "memory"

**JVM Heap:** 450 MB

Hope to see your feedback and suggestion.

Thank you.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 8, 2022, 9:03am UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737/2 "2022-01-08T09:03:32Z")

</div>

I believe I have seen Elasticsearch run with a heap of 512MB but that assumes very light usage as there is a certain amount of static overhead. For any kind of intense usage a would expect a significantly larger heap to be required. Playing with circuit breakers is the wrung thing to do when you have a heP the small IMHO.

I would recommend removing any custom circuit breaker setting and instead increasing the heap to 1GB to see if that helps. Depending on your load, data volume and queries this may need to be increased further.

---

<div class="post-metadata">

**Author:** ![Suresh\_Ghatuwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suresh_ghatuwa/32/99976_2.png) [@Suresh\_Ghatuwa](https://discuss.elastic.co/u/Suresh_Ghatuwa)\
**Post date:** [January 9, 2022, 1:24am UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737/3 "2022-01-09T01:24:13Z")

</div>

**JVM Heap:** 450 MB is just for testing Circuit Breaker. It is not actually implemented for deployed.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 9, 2022, 6:16am UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737/4 "2022-01-09T06:16:16Z")

</div>

Look at how much heap is used just after you have started up the node and it is in green state. That could well be most of it if you have indexed some data.

The default circuit breaker settings have sensible values that generally do not need to be tuned. I do not see the point in tuning them for a very small heap size that will not be used later on.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 9, 2022, 9:28pm UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737/5 "2022-01-09T21:28:41Z")

</div>

I agree with Christian here.

---

<div class="post-metadata">

**Author:** ![Suresh\_Ghatuwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suresh_ghatuwa/32/99976_2.png) [@Suresh\_Ghatuwa](https://discuss.elastic.co/u/Suresh_Ghatuwa)\
**Post date:** [January 10, 2022, 3:52am UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737/6 "2022-01-10T03:52:46Z")

</div>

Apology for low heap size. There is 2 indices having each 950 MB index size and 5M document.

What about using **JVM HeapSize: 5GB**. And executing heavy es queries having multiple terms aggregation and cardinality. Also, similar queries are executing parallelly.

Can we throw a circuit breaker exception to the overall JVM exceeding limit? When I perform tests, it is not throwing an exception on exceeding overall JVM heap. Instead, when required JVM exceed the limit for a single query, it is throwing an exception.

OR

Could you please provide more information on how a circuit breaker works for a single query and parallel ES queries?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 10, 2022, 4:03am UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737/7 "2022-01-10T04:03:26Z")

</div>

Whit this 5GB heap size, are you using the default settings? What happens during high load? Are you monitoring heap usage? Is there anything in the logs?

---

<div class="post-metadata">

**Author:** ![Suresh\_Ghatuwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suresh_ghatuwa/32/99976_2.png) [@Suresh\_Ghatuwa](https://discuss.elastic.co/u/Suresh_Ghatuwa)\
**Post date:** [January 10, 2022, 5:02am UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737/8 "2022-01-10T05:02:57Z")

</div>

JVM increased and shows Out Of Memory in log. Also, there is some others log when JVM is Increasing.

_[2022-01-10T10:46:33,878][WARN][o.e.m.j.JvmGcMonitorService] [Node1] [gc][1756] overhead, spent [881ms] collecting in the last [1s]_

Yes, I am monitoring from **Kibana Stack Monitoring**.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 10, 2022, 8:20am UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737/9 "2022-01-10T08:20:07Z")

</div>

That sounds like a very long collection time for such a small heap. Do you have swap enabled or are you maybe running on a VM with memory ballooning?

Does this happen with default settings? What load is the cluster under? How much total memory does the host have?

---

<div class="post-metadata">

**Author:** ![Suresh\_Ghatuwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suresh_ghatuwa/32/99976_2.png) [@Suresh\_Ghatuwa](https://discuss.elastic.co/u/Suresh_Ghatuwa)\
**Post date:** [January 10, 2022, 9:00am UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737/10 "2022-01-10T09:00:50Z")

</div>

Currently, I am testing locally in mac with 16 GB RAM. Yes, swap is enabled. I had tested in AWS EC2 instance as well.

Yes, it happens in default settings as well.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 7, 2022, 9:01am UTC](https://discuss.elastic.co/t/circuit-breaker-exception/293737/11 "2022-02-07T09:01:46Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
