Roll Over Rollups! The Big Future of Ophan's Historical Data

7 Jun 2023

Problem

The Guardian's in-house real-time analytics tool Ophan shows editors pageviews for the last two weeks, backed by an Elasticsearch store. Editors also need multi-year views by section, desk or topic to plan strategically. Keeping years of raw pageviews in Elasticsearch is costly, so the team used Elasticsearch Rollups, which summarise old data into a coarser format. Rollup aggregations turned out to return wrong rankings. The feature had also been in technical preview since March 2018, with no support commitment.

Example from the article: a "Top 50 articles published in 2021" query returned, in some scenarios, only 6% of the correct results when compared with the data warehouse.

Solution in brief

Instead of aggregating inside the search store, the team pre-aggregates pageviews in the data warehouse (BigQuery) on a schedule and lets the dashboard query those small tables. Partitioning, clustering and reserved slots keep queries fast and predictable. The accuracy problem was found by checking the store's answers against the warehouse.

Questions this case answers
  • How to serve long-horizon top-N aggregates to non-technical users accurately and at low query cost when the pre-aggregation layer of the serving store returns wrong rankings
  • How to give editors multi-year pageview rankings from a real-time analytics tool without storing all history in the search store?
  • How to check that an aggregation layer returns correct top-N results before building features on it?
  • How to serve fast dashboard queries from a data warehouse that is too big to aggregate on the fly?

Tools and methods

  • Elasticsearch — real-time store for the last two weeks; Rollups were used for history
  • BigQuery — warehouse and serverless query engine behind the historical views
  • dbt — models the warehouse transformations and aggregations
  • Apache Airflow — DAGs that refresh the pre-aggregated tables periodically
  • Workload Identity Federation — keyless access from AWS instances to GCP
  • Architecture decision record — format used to re-evaluate the options
Continue reading — it's free

Google or a one-time email code. No password.