Systems · Week 6

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

  1. Why not OLTP per impression?
  2. What does windowed aggregation do?
  3. When must counts be exact?
  4. How do sketches fail?
  5. 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.