At a glance
Key concepts and capabilities
COUNT(DISTINCT) is a trapUse cases
Counting clicks per minute, at a billion a day
The standard pipeline: events land in Kafka, a stream processor windows and pre-aggregates them, and the rollup table is what the dashboard queries. The batch path exists because streams get late and duplicate events wrong, and recomputing a partition is the cheapest way to make the numbers finally correct.
A rollup for the dashboard, raw rows for the drill-down
Two tables, and knowing which query hits which is the design. The rollup is bounded — a handful of dimensions, one row per minute per combination — and the raw table keeps the high-cardinality columns for the rare query that needs a single user or request.
Keeping the bill sane as data ages
Retention is a partition operation, not a DELETE. Recent partitions stay on
fast disk, older ones are tiered to object storage, and the oldest are dropped
whole — which is also the answer to "what does keeping a year of this cost?"