Real-Time Analytics Systems
Master real-time analytics systems: streaming ML, low-latency inference, feature streaming, online learning, and production deployment.
What is a real-time analytics system?
A real-time analytics system continuously turns events into recent metrics, features, predictions, or actions within a declared freshness deadline. Unlike a batch job, it must reason about event time, late and duplicate data, state recovery, backpressure, and how partial failure changes the result.
"Real time" is a product contract, not a technology label. A fraud decision may need tens of milliseconds, an operational alert seconds, and a dashboard minutes. Choose the simplest architecture that meets the actual deadline and correctness requirement.
Real-Time Analytics Calculator
Calculate throughput, latency, memory usage, and scaling requirements for streaming analytics.
Performance Analysis
- Events/sec
- 100,000
- Events/partition
- 8,333
- Total Latency
- 72ms
- Window Memory
- 5859 MB
- Total Memory
- 6066 MB
- Latency Class
- Sub-100ms
- Recommended Partitions
- 13
- Recommended Instances
- 4
Trace the streaming architecture under failure
Four semantics determine correctness
When it happened
Event time
Use source timestamps for windows when network or processing delay would otherwise assign an event to the wrong period.
How long to wait
Watermark
Estimate how complete event-time progress is. The allowed-lateness policy trades lower delay for fewer corrections.
Recoverable memory
State and checkpoint
Window aggregates, joins, and model features need durable snapshots tied to input positions so a restart can reproduce results.
Safe replay
Idempotent effect
Use stable event and result keys so retries or replay do not double-charge, double-alert, or corrupt an aggregate.
"Exactly once" is an end-to-end property. A framework checkpoint cannot prevent duplicate business effects unless the sink participates transactionally or deduplicates idempotently.
Follow one late event through correction and recovery
Consider a ten-second order-count window from 10:00:00 through 10:00:10, with 30 seconds of allowed lateness:
- Event time: order
order-4821is created at10:00:04, so it belongs to the10:00:00window even though a network retry delays it. - Processing delay: the event reaches the processor at
10:00:20. The current watermark is10:00:15, so the window has already emitted a count of126. - Allowed lateness: the event is late because the watermark passed the window end, but it is still accepted because the watermark has not passed
10:00:40(window end plus 30 seconds). - State and correction: keyed window state adds
order-4821and changes the count from126to127. This is a correction to the existing output, not a change that affects only future windows. The analytical sink upserts keyorders:10:00:00with value127. - Failure: the sink accepts the upsert, but the processor crashes before the next checkpoint completes. The last completed checkpoint,
841, contains source offset2048and the earlier count of126. - Recovery and replay: the replacement processor restores checkpoint
841, resumes from offset2048, and readsorder-4821again. Restored state moves from126to127, while the sink overwrites the sameorders:10:00:00key with the same result. - Business-effect deduplication: if the correction also opens an alert, the alert write uses the unique effect key
late-correction:10:00:00:order-4821. Replay finds that key already committed and does not page an operator twice.
Once the watermark passes 10:00:40, the system removes this window's correction state. An event for the same window arriving after that point follows the declared too-late policy: this design sends it to a reviewable side output and does not alter the published count.
The mechanics match Apache Flink's primary documentation: window lifecycle and allowed lateness explain late firings as updated results, while fault tolerance via state snapshots explains checkpoint replay and why end-to-end exactly-once behavior requires a transactional or idempotent sink.
Build features and decisions from one event contract
Online learning adds a second state transition: the model itself changes. Keep updates versioned, bounded, and independently evaluable.
The serving API should expose freshness and version metadata so downstream systems can distinguish a fresh prediction from a degraded fallback.
Bound feedback loops and overload
- Separate observed outcomes from model-influenced exposure; the stream contains selected evidence, not an unbiased view of the world.
- Keep an exploration or control channel where safe so new behavior can still be measured.
- Cap queues and state. Backpressure should slow, shed, or divert lower-priority work before memory exhaustion.
- Send malformed or repeatedly failing events to a reviewable dead-letter path instead of retrying forever.
- Gate online model updates with independent evaluation and a rollback artifact.
- Define whether late events correct prior outputs, update only future state, or are intentionally discarded.
Production readiness questions
- Which result is authoritative when replay produces a corrected value?
- How much lateness can the product tolerate before a window is final?
- Can every side effect be retried without duplication?
- Does a processor restart restore state and input offsets from the same checkpoint?
- What happens when the model, feature sink, or analytical store is unavailable?
- Which signals prove freshness, lag, state growth, data quality, and decision quality remain acceptable?