Skip to content

[RFC] Pre Compute Aggregations with Star Tree index #12498

Open
@bharath-techie

Description

@bharath-techie

Is your feature request related to a problem? Please describe

Aggregations are the most used query type in observability use cases and the aggregation is typically on metrics, request logs, etc. and spread across different fields. Heavy aggregation queries doesn’t have an upper bound in terms of time taken and resource consumption. In general, the performance of an aggregation query is relative to the number of documents.

Aggregations are faster when they are run on rolled up indices and transforms as they help in reducing granularity and providing materialized views. But, they are generally done once ingestion is complete, similar constructs doesn’t exists for live/active data.

Existing solutions

Aggregation framework

Existing aggregation framework in OpenSearch is quite powerful with bucket, pipeline and metric aggregations. It does support wide range of aggregations since it operates on the non altered live documents of the indices. And as it operates on live original data, deletes and updates are also supported.

While it works great, it has few cons

  • Query latency scales linearly with the number of documents.
    • For example, aggregation which measures count of ‘status’ in the HTTP logs workload in OSB, takes a lot longer for '200' status [~200M documents] compared to '400' status [~3000 documents]
  • If there are multiple aggregations on different fields, each field / aggregation is processed separately and in general it leads to higher query latencies.
    • The following example captures query time as user adds more aggregations:
      • if user queries on status = 200 + aggregation of sum (size) = ~4s
      • if user queries on status = 200 + aggregations of sum (size) , avg(size) = ~6s
      • if user queries on status = 200 + aggregations of sum (size) , avg(size) , max(size) = ~7.5s

Index rollups / Index transforms

Index rollup jobs lets users reduce data granularity by rolling up old data into condensed indices, transform jobs lets users create a different, summarized view of users' data centered around certain fields. These solutions are generally used to save storage space and also the queries are faster as the number of documents are reduced.

Cons:

  • These solutions are generally used to reduce granularity of older data and not used on real time data.
  • Configuring the jobs and managing the indices is cumbersome.
    • Cannot search a mix of rollup and non-rollup indexes with the same query
    • Initial rollup job can become expensive depending on the size of the data

Describe the solution you'd like

Star tree index

I’m exploring the use case of pre-computing the aggregations using Star Tree index while indexing the data based on the configured fields (dimensions and metrics) during index creation. This is inspired from http://hanj.cs.illinois.edu/pdf/vldb03_starcube.pdf and Apache Pinot’s Star Tree index. Star Tree helps to enforce upper bound on the aggregation queries ensuring predictable latency and resource usage, it is also storage space efficient and configurable.

Star Tree index is a multi-field index, contrary to existing index structures in Lucene and OpenSearch which are on single field.

Improvements with Star Tree index

  • Users can perform faster aggregations with a constant upper bound on query latency.
  • Star tree natively supports multi field aggregations.
  • Star tree index will be created in real time as part of regular indexing, so the data in star tree will always be up to date with the live data.
  • Star tree index consolidates the data and is a storage efficient index, and hence brings following benefits
    • Complex aggregation queries will cause fraction of IO utilization compared to present solutions.
    • Paging also will be more efficient as less data gets paged for every star tree query

While it provides the above improvements, it does have its limitations, they are:

  • Star tree index will be created only on append-only indices, updates or deletes will not be supported.
  • Star tree index will be used for aggregation queries only if the query input is a subset of the star tree configuration of dimensions and metrics
  • Star tree index will support limited set of aggregations such as MIN, MAX, COUNT, SUM, AVG. Others are yet to be explored
  • The cardinality of the dimensions should not be very high (like _id fields), otherwise it leads to storage explosion and higher query latencies.
  • Changing Star Tree config (dimension or metrics) will require a re-index operation.

Given the above details, it does makes a case on why Star Tree is valuable to OpenSearch, I’m working on prototyping it. I’ll follow up on this issue with prototype details along with the benchmark results.

Related component

Search:Aggregations

Describe alternatives you've considered

Mentioned in the Existing Solutions.

Additional context

No response

Metadata

Metadata

Labels

IndexingIndexing, Bulk Indexing and anything related to indexingPerformanceThis is for any performance related enhancements or bugsRFCIssues requesting major changesRoadmap:Cost/Performance/ScaleProject-wide roadmap labelSearchSearch query, autocomplete ...etcSearch:AggregationsSearch:PerformanceenhancementEnhancement or improvement to existing feature or requestlucenev2.17.0

Type

No type

Projects

Status

Later (6 months plus)

Status

Open

Status

New

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions