# Compile rate limit for painless scripts

**URL:** <https://discuss.elastic.co/t/compile-rate-limit-for-painless-scripts/263421>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [February 5, 2021, 3:34pm UTC](https://discuss.elastic.co/t/compile-rate-limit-for-painless-scripts/263421 "2021-02-05T15:34:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dineshabbi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dineshabbi/32/56301_2.png) [@dineshabbi](https://discuss.elastic.co/u/dineshabbi)\
**Post date:** [February 8, 2021, 10:32am UTC](https://discuss.elastic.co/t/compile-rate-limit-for-painless-scripts/263421/2 "2021-02-08T10:32:02Z")

</div>

Also came across this thread:

> [@Will Increasing the setting script.max\_compilations\_rate from 75/5m to 300/m effect perfomance?](https://discuss.elastic.co/t/will-increasing-the-setting-script-max-compilations-rate-from-75-5m-to-300-m-effect-perfomance/240781):
>
> I'm getting remote transport exception while executing painless scripts. Need to know if it will really effect performance, if we increase from its actual limit i.e 75/5m to 200-300/1m. if not, is there any alternative wayto avoid this exception? Can stored scripts help for this case?

In my measurement where I bumped up the `max_compilations_rate` manually via persistent cluster settings, I noticed significant degradation in update latency. In my test, I am running 10000 updates/minute and all 10000 push unique painless script.

Also, I am using elasticsearch 7.5 and the I was not able to change `cache_size` or `cache_expire` dynamically. I was able to change only `max_compilations_rate` setting. These attributes are context based in later releases of elasticsearch, but we are not planning to move to later versions of easlticsearch at the moment.

We are concluding that the cache eviction/reload comes with a compilation overhead even for stored scripts. One logical explanation I could think of is - if the stored script was not cached, and was updated in the backend, then they have to be recompiled before loading them into cache again. That's the only explanation I could think of for recompiling stored script every time when we reload them into cache.

Compilation overhead results into much slower update, impacting update latency by an order of magnitude.

---

_[View the full topic](https://discuss.elastic.co/t/compile-rate-limit-for-painless-scripts/263421)._
