Impressions counting
High-rate counters with approximation and aggregation windows.
Impressions counting
Business constraint
Ads/feed impressions arrive at huge QPS. Dashboards need near-real-time totals with known error.
Naive v0
Write every impression to OLTP. Or exact global counter key.
Failure drill
Storage and write path melt. Hot keys. Dashboards lag hours when switched to batch too late.
Evolution path
Iteration 1
Client/server aggregation windows. Shard counters. Approximate sketches where contract allows.
Iteration 2
Append-only raw sample / log for audit; derived counters for UI.
Iteration 3
Separate billing-grade exact paths from UX-grade approximates explicitly.
Implementation cut
Product-label approximate metrics. Never silently use UX counters for money.
Numbers
Error bound vs truth sample. Write QPS after aggregation. Dashboard freshness.
Pattern tags
Self-check
- Why not OLTP per impression?
- What does windowed aggregation do?
- When must counts be exact?
- How do sketches fail?
- Why label approximate UX metrics?
Walkthrough
Recordings will appear here when published. Until then, work the failure drill and lab locally — pause after each iteration and write the metric that moved.