Build a Real-time Analytics Platform — System Design Interview Practice
Design a real-time analytics solution that ingests millions of events, processes streaming data, detects patterns, and triggers actions based on analytics. Work through the requirements, architecture trade-offs, and an interactive design review.
Concepts and architecture decisions to consider
- azureConcept to explore
- event hubsConcept to explore
- stream analyticsConcept to explore
- real timeConcept to explore
- analyticsConcept to explore
Interview prompt
Design a streaming analytics platform that ingests events from many sources, evaluates windowed patterns, maintains low-latency projections, and triggers reliable downstream actions.
- Define event contracts, partition keys, watermarks, windows, joins, state retention, trigger semantics, and delivery guarantees.
- Partition streams by workload/key, isolate hot keys, handle late/duplicate/out-of-order events, and make state checkpoints/replay explicit.
- Separate durable ingestion from stream operators, materialized views, action sinks, exploratory queries, and batch backfills.
- Explain schema evolution, backpressure, poison events, exactly-once effects, observability, and degraded projections.
Requirements and scale assumptions
- Register sources and schemas, ingest events, run windowed SQL/pattern operators, publish aggregates, and trigger idempotent actions.
- Expose job health, lag/watermarks, query results, pattern matches, output freshness, replay controls, and tenant usage.
- Support reprocessing, schema versions, deletion/tombstones, dead-letter handling, checkpoint restore, and sink reconciliation.
- Publish standard window results and actions within five seconds while exposing lag and incomplete-window state.
- Process 1M events per second across thousands of jobs without a single hot key or unbounded synchronous work.
- Do not lose committed state; make retries and duplicate events safe.
- Degrade safely when downstream workers, caches, or external dependencies fail.
- 1M events/second, 10k streaming jobs, and 100k action sinks
- Partition by the primary tenant, user, item, or geographic key and isolate hot partitions.
- Keep serving state bounded; retain raw events or durable records for replay and auditing.
- Peak scale: 1M events/s; 10k jobs — Capacity assumption that drives partitioning and backpressure.
- Latency target: window result p95 < 5s; lag visible — User-facing budget for the primary request or read path.
- Durable boundary: Committed before async — Accepted events and operator/checkpoint definitions are authoritative; views and actions are derived effects.
- Async boundary: At-least-once workers — Keep Event Hubs for event ingestion, Stream Analytics for processing, Cosmos DB for output storage off the synchronous path.
Key entities
- SourcePartitionsourceId, partitionId, cursor, schemaVersion, watermark, status
Replayable real time analytics platform source evidence and ingestion cursor.
- SchemaVersiondatasetId, version, compatibility, owner, effectiveAt, status
Governed real time analytics platform contract used to validate producers and consumers.
- ProcessingRunrunId, inputWatermark, checkpoint, qualityStatus, codeVersion, status
Checkpointed real time analytics platform processing attempt with quality and lineage metadata.
- AnalyticalDatasetdatasetId, partition, watermark, schemaVersion, qualityStatus, location
Curated real time analytics platform serving partition with freshness and quality state.
Data flow
- 1. Register sources and contractsThe real time analytics platform catalog records owners, schemas, compatibility rules, retention, lineage, and partitioning before data is accepted.
- 2. Ingest with backpressureConnectors checkpoint real time analytics platform source cursors, validate schema and deduplication keys, and slow producers when downstream capacity is exhausted.
- 3. Process event time with checkpointsStream or batch engines compute real time analytics platform transformations using watermarks, late-data policy, state checkpoints, and deterministic code versions.
- 4. Publish quality-gated datasetsOnly real time analytics platform outputs that pass completeness, freshness, validity, and privacy checks become visible to analytical consumers.
- 5. Serve, replay, and reconcileConsumers read bounded partitions with freshness metadata while operators replay failed real time analytics platform ranges and compare output checksums.
Deep dives and trade-offs
- Schema evolution and data qualityVersion real time analytics platform contracts and make compatibility rules explicit for every producer and consumer. Quarantine malformed partitions instead of poisoning the whole dataset. Track row counts, null rates, duplicates, distribution changes, and policy violations by partition.
- Watermarks, late data, and exactly-once effectsUse source cursors and event-time watermarks for real time analytics platform progress, not wall-clock assumptions. Make checkpoints, output keys, and sink commits retry-safe under at-least-once delivery. Document how late events revise windows, aggregates, or snapshots.
- Replay, lineage, and costKeep immutable real time analytics platform raw evidence and code or schema versions so failed outputs can be reproduced. Separate hot serving storage from cold retention and cap replay concurrency. Measure freshness, backlog, compute cost, storage growth, and quality-gate failure rate.
- Streaming versus batchUse streaming for freshness-critical real time analytics platform paths and batch for backfills, compaction, and expensive recomputation. Forcing every workload into streaming makes state, replay, and cost harder to operate.
- Raw retention versus curated-only storageRetain enough immutable raw evidence for replay, audit, and correction, then tier or expire it according to policy. Without raw evidence, a bad transformation can require an unreproducible emergency fix.
- Central warehouse versus domain-owned datasetsCentralize governance and discovery while letting domain owners own contracts and quality signals. A single team owning every transformation becomes a delivery bottleneck and hides data ownership.