Skip to main contentSkip to user menuSkip to navigation

Real-Time Analytics Systems

Master real-time analytics systems: streaming ML, low-latency inference, feature streaming, online learning, and production deployment.

55 min readAdvanced
Not Started
Loading...

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:

  1. Event time: order order-4821 is created at 10:00:04, so it belongs to the 10:00:00 window even though a network retry delays it.
  2. Processing delay: the event reaches the processor at 10:00:20. The current watermark is 10:00:15, so the window has already emitted a count of 126.
  3. 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).
  4. State and correction: keyed window state adds order-4821 and changes the count from 126 to 127. This is a correction to the existing output, not a change that affects only future windows. The analytical sink upserts key orders:10:00:00 with value 127.
  5. Failure: the sink accepts the upsert, but the processor crashes before the next checkpoint completes. The last completed checkpoint, 841, contains source offset 2048 and the earlier count of 126.
  6. Recovery and replay: the replacement processor restores checkpoint 841, resumes from offset 2048, and reads order-4821 again. Restored state moves from 126 to 127, while the sink overwrites the same orders:10:00:00 key with the same result.
  7. 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

Event-time feature pipeline

Online learning adds a second state transition: the model itself changes. Keep updates versioned, bounded, and independently evaluable.

Controlled streaming model updates

The serving API should expose freshness and version metadata so downstream systems can distinguish a fresh prediction from a degraded fallback.

Real-time analytics API

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?
No quiz questions available
Could not load questions file
Spotted an issue or have a better explanation? This page is open source.Edit on GitHub·Suggest an improvement