Closed
Description
In a recent discuss forum post a user reported circuit breaking exceptions when using a large number of avg
aggregations nested under two layers of terms
aggregations.
Internally, the estimated memory cost of handling the request was (badly) estimated to be nearly 3GB in size but the actual size should have been much smaller. In part, this is due to a one-size-fits-all cost which is added for every aggregation which is hard-coded to 5kb in the aggregator base class.
For some aggregations this is often an underestimate (e.g. cardinality agg) while for simple metric aggregations like the avg
aggregation it is a large over-estimate (which led to the circuit breaker error in the case mentioned above).
The solution requires
- A change to AggregatorBase to allow subclasses to override a new "getWeight" method.
- Changes to metric aggregations like
avg
to provide a better estimate of their memory cost.