ElasticSearch inine script, max_compilation_rate issue

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


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
`

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?

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