Leaderboard & Counting Service  ·  View 10 of 21  ·  Data

Counting Data Flow

One stream, two destinations: the aggregation that feeds the screen and the archive that makes it disposable.

Editable source SVG draw.io All views
Sources Session completion Vote or reaction View or play Round result Admit Validate schema, bounds Dedup idempotency key Classify key hot or median Hold if suspect Durable log Event log Pub/Sub 31 d Archive writer Avro to GCS Event archive 90 d hot, 13 mo cold Aggregate Event-time windows hour buckets Exact sums HLL++ uniques ≤ 2% at p95 Late bucket Project Bucket store Bigtable Window compose bucket addition Ranked view vN Rank histogram Serve & export Rank cache Memorystore Query API Warehouse BigQuery replay Leaderboard & Counting Service — Counting Data Flow External / third party Application we own Security / platform Queue / topic Data store Interface / broker batch One stream, two destinations: the live aggregation that feeds the screen, and the archive that makes every projection downstream of it disposable. The warehouse export runs off the archive (view 11). v 1.0 · owner Platform Architecture · date 2026-10

Decisions

  • The log is written twice by design: a 31-day live topic for streaming delivery and an archive for 90-day replay. One is a transport, the other is the record; conflating them means the retention of the record is set by the broker's limits.
  • Uniqueness is counted with a sketch rather than a member set, because storing the member set is what makes a distinct-viewer counter cost more than the view counter it accompanies.
  • Late events beyond the declared horizon land in a visible late bucket rather than being dropped or silently folded in.

Numbers (assumptions)

  • Event archive 25 TB per 90 days after compression; hot for 90 days, archive class to 13 months.
  • Approximate unique counters ≤ 2% relative error at p95, ≤ 5% at p99.
  • Finest bucket is one hour; a 7-day window composes from 168 of them.

Risks

  • A bucket-addition read for a 30-day window is a 720-bucket fan-in. Either coarser roll-ups are maintained or the window set stays small.
  • Writing the log twice doubles the ingest cost floor and adds a consistency question between the two copies at the boundary of a replay.