# ElasticSearch inine script, max\_compilation\_rate issue

**URL:** <https://discuss.elastic.co/t/elasticsearch-inine-script-max-compilation-rate-issue/238082>\
**Category:** Elasticsearch\
**Created:** [June 22, 2020, 12:05pm UTC](https://discuss.elastic.co/t/elasticsearch-inine-script-max-compilation-rate-issue/238082 "2020-06-22T12:05:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkr57123](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@rkr57123](https://discuss.elastic.co/u/rkr57123)\
**Post date:** [June 22, 2020, 12:05pm UTC](https://discuss.elastic.co/t/elasticsearch-inine-script-max-compilation-rate-issue/238082/1 "2020-06-22T12:05:54Z")

</div>

`Hi,

I'm using elastic-7.3.1.  
I'm sending large number of requests each having unique dynamic inline script and I'm getting this issue on elastic server  
**org.elasticsearch.ElasticsearchException: Elasticsearch exception [type=circuit\_breaking\_exception, reason=[script] Too many dynamic script compilations within, max: [75/5m]; please use indexed, or scripts with parameters instead; this limit can be changed by the [script.max\_compilations\_rate] setting]**

To resolve this i have first updated max\_compilation\_rate to 100/5m but it didn't resolve the issue.

And also we can't keep increasing this parameter due to infrasturcture limitation. So can you please suggest a way out here to tune max\_compilation\_rate?

Secondly,  
I read on elastic documentation page, script.cache.max\_size = 100 by default.  
Is there any relation between max\_compilation\_rate and script.cache.max\_size?  
Since I found a corelaiton between them while experimenting.  
I was sending 3 unique dynamic inline script in a minute then i observed a corelation between max\_compilation\_rate and script.cache.max\_size as attached here.

 ![es_query](https://us1.discourse-cdn.com/elastic/original/3X/c/d/cdc4d0bde65d4fbee336121b9118e73172675e75.png)  
So please look into and let me know, it's right or wrong?

And one more, are stored scripts and inline scripts both counted for script.cache.max\_size limitation? I mean, stored\_script + inline\_script = script.cache.max\_size or only inline\_script = script.cache.max\_size or something else?

Thanks a lot.  
Rajnish  
`

---

<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:** [June 23, 2020, 4:47am UTC](https://discuss.elastic.co/t/elasticsearch-inine-script-max-compilation-rate-issue/238082/2 "2020-06-23T04:47:06Z")

</div>

Can you please describe the use case and how you use scripts? Is there a reason you can not standardise scripts and use passed parameters to reduce the number of compilations?

---

<div class="post-metadata">

**Author:** ![rkr57123](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@rkr57123](https://discuss.elastic.co/u/rkr57123)\
**Post date:** [June 23, 2020, 10:43am UTC](https://discuss.elastic.co/t/elasticsearch-inine-script-max-compilation-rate-issue/238082/3 "2020-06-23T10:43:06Z")

</div>

@Christian_Dahlqvist thanks for the response.

Here is the script which I'm using to compute some data:-  
{  
"aggs": {  
"group\_by\_col": {  
"scripted\_metric": {  
"map\_script": "if (doc['abc'].value=='F'){if(params['\_source']['col1)'] != ''){if(doc['col1)'].value \< 10){val1++; }else{val2++}}}else{if(params['\_source']['col1)'] != ''){if(doc['col1)'].value \< 10){val2++; }else{val1++}}}",  
"init\_script": "params.\_agg['map'] = ['val1':0, 'val2':0]",  
"reduce\_script": "params.result = ['Default':{Default}, 'Target':{Target}, 'Breach':{Breach}, 'res1':10]; if(params.result.res1 \<= (int){Low Volume}){params.result.Target = 10; params.result.Breach = 20; params.result.Default = 30;} return params.result"  
}  
}  
},  
"size": 0,  
"query": {  
"bool": {  
"must": [  
{  
"match": {  
"id": "\_id"  
}  
}  
]  
}  
}  
}

I'm using standardise scripts but we are sending too many requests that's why getting this error.

Hope it will help to figure out the issue.

---

<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:** [July 21, 2020, 10:43am UTC](https://discuss.elastic.co/t/elasticsearch-inine-script-max-compilation-rate-issue/238082/4 "2020-07-21T10:43:28Z")

</div>

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