How we built it: Real-time analytics for Stripe Billing

Reed Trevelyan16 Sep 2025

Problem

Stripe Billing customers explore subscription metrics (monthly recurring revenue (MRR) growth, churn, trial conversion) in the Dashboard. A subscription's current state depends on its whole history, so the old system recomputed each state from the beginning of time in batches, and the data lagged by 24 hours on average. Customers can also redefine a metric, so history must be recomputed while new events keep coming.

Example from the article: a customer decides to exclude one-time coupons from MRR. For an account that has existed since 2017, reprocessing the history takes hours, and the Dashboard must stay consistent in the meantime.

Solution in brief

Stripe turns subscription and invoice updates into analytics events and folds them into compact per-subscription state in Apache Flink. Spark builds that state for old accounts in parallel. Pinot's windowed queries replace offline pre-aggregation. A metric-definition change runs as a batch recompute while live events are buffered, then the recomputed history is patched into the stream state.

Questions this case answers
  • How to keep a derived metric fresh within minutes when its value depends on the full event history of each entity
  • How to change a metric definition and recompute history while live events keep arriving, without showing inconsistent numbers
  • How to show subscription metrics such as MRR, churn and trial conversion within minutes instead of a day?
  • How to compute the current state of a subscription without re-reading its whole history on every batch?

Tools and methods

  • Apache Flink — keeps a compressed subscription history as state and updates it incrementally per event
  • Apache Spark — runs the same logic as a batch job to build initial Flink state and validation files
  • Apache Pinot (v2 engine) — OLAP store with windowed queries and joins
  • Ingestion-time aggregation — folds each event into running state instead of re-reading history
Continue reading — it's free

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