Google SD

Design Google Global Real-time Analytics

Unified metrics across Search, Ads, YouTube — stream processing + batch correction at planetary scale.

Interview tip Lambda architecture: Kafka/Pub/Sub → Flink speed layer + BigQuery batch; mention exactly-once, regional aggregation, global merge.

① Functional requirements

  • Collect events from all product surfaces
  • Real-time dashboards (last hour)
  • Accurate daily reports
  • Alerting on anomaly thresholds
  • Per-product and global views
  • Role-based access to metrics

② Non-functional requirements

  • Speed layer latency < 1 minute
  • Trillions of events/day
  • No double-count in aggregates
  • Regional fault isolation

③ Back-of-the-envelope scale

Assumptions
  • Trillions events/day
  • Flink on Kafka
  • BigQuery batch reconcile nightly

④ High-level architecture

Global Analytics
Product event collectors
Pub/Sub global bus
Flink speed layer
BigQuery batch layer
Serving + dashboards

⑤ Data flow & execution path

Event to metric
EventRegional aggregateGlobal mergeDashboard
Watermarks for late events
Batch layer fixes speed approximations

⑥ API & interfaces

Endpoint / flowPurposeNotes
POST /eventsHigh-volume ingestbatched
GET /metricsQuery APIscoped by product

⑦ Data model & storage

Domain-specific entities sharded by user_id or geographic key.
StoreWhatWhy
Distributed storePrimary dataSharded for scale
Kafka / Pub/SubEvent logAsync pipelines
Object storeMedia / blobsGCS-style durability

⑧ Deep dive — core components

Lambda merge

Dashboard queries sum speed layer (today) + batch tables (history) with documented staleness.

Cardinality control

HyperLogLog for UV; rollups pre-aggregate high-cardinality dimensions.

⑨ Trade-offs & alternatives

DecisionOption AOption BPick when
ProcessingFlinkSpark StreamingFlink lower latency ops
AccuracyApproximate RTExact batchStandard lambda trade-off

⑩ 45-minute interview script

  1. 0–5 min: Requirements + Google-scale assumptions
  2. 5–12 min: Back-of-envelope QPS and storage
  3. 12–22 min: Architecture diagram
  4. 22–35 min: Deep dive on hot path
  5. 35–42 min: Failure modes and trade-offs

⑪ Likely follow-up questions

QuestionShort answer
How roll out globally?Regional cells + gradual feature rollout

⑫ Revision checklist

  • Pub/Sub ingest
  • Flink speed
  • BigQuery batch
  • Lambda merge
  • HLL for UV
  • Late data
googleanalyticslambdaflink