#37View Count on a Video/Post
Dedup, bot-filter, batched aggregation.

Count the views on a video or post. It sounds like count++; it is one of the harder write-heavy distributed-systems problems in practice. The work is dominated by three pressures the naive version ignores: dedup (the same viewer reloading must not inflate the number), bot / invalid-traffic filtering (a large fraction of raw "views" are not humans, and the public number must be reported net of them), and batched aggregation (you cannot synchronously increment a row per view at 250k views/sec — you log an idempotent event and roll it up asynchronously). The system is also read-dominated for the display of the count and hot-keyed on the write of a viral video, so it pulls in opposite directions at once.

This canonical models the main flows: the ingest/write path, the read path that displays the count, the speed-layer aggregation that produces the fast approximate number, and the batch "verified-views" layer that produces the authoritative one — the layer behind YouTube's famous 301+ freeze and the reason counts sometimes go down.

Reading: Netflix Distributed Counter Abstraction (TechBlog, 2024) · Cloudflare HTTP analytics @6M req/s on ClickHouse · Reddit View Counting (HLL + Kafka + Cassandra) · Twitter TSAR / Summingbird + Manhattan · LinkedIn 'Who Viewed Your Profile' on Apache Pinot · Ably: Cassandra counter columns — nice in theory, hazardous in practice · Google Ad Manager GIVT/SIVT invalid-traffic methodology
fire-and-forget event log
idempotent counter rollup
HyperLogLog uniques
bot / invalid-traffic filtering
sharded counters & hot keys
lambda batch reconciliation
monotonic serving