Volume 14 · Chapter 7 — Enterprise Software Architecture Case Study Encyclopedia
Real-Time Distributed Systems
7.1 Introduction
Real-time distributed systems - live dashboards, notifications, collaborative apps, IoT, real-time fraud - process continuous streams of events and push updates to many clients with low latency. Their defining challenges are handling high-volume event streams, pushing data to clients in real time (a different communication model from request/response), and doing both at scale with fault tolerance. This case study covers the streaming and push architecture and the consistency trade-offs it forces.
7.2 Reference Architecture
flowchart TB
Clients["Clients (browsers/devices)"] <--> RT["Real-Time Gateway\n(WebSocket / SSE)"]
Sources["Event sources"] --> Ingest["Ingestion (Event Hubs/Kafka)"]
Ingest --> Stream["Stream Processing\n(aggregate, filter, enrich)"]
Stream --> Pub["Pub/Sub (backplane)"]
Pub --> RT
Stream --> Store[("Materialized views / state")] 7.3 Pushing Data to Clients
Real-time delivery inverts the usual request/response model - the server pushes to clients. The mechanisms are WebSockets (bidirectional, for interactive apps), Server-Sent Events (one-way server-to-client streaming), and pub/sub. In .NET, SignalR abstracts these and, with a backplane (Redis), scales connections across many server instances - because a real-time gateway must maintain millions of persistent connections and fan out updates to the right subscribers.
7.4 Stream Processing at Volume
The event side is a high-throughput streaming problem: ingesting massive event volumes (Event Hubs/Kafka), processing them (aggregation, filtering, enrichment, windowing) with stream-processing engines, preserving per-key ordering via partitions, and handling faults so no events are lost. Materialized views hold the current state that new clients need on connect.
7.5 Consistency and Fault Tolerance
Real-time systems almost always choose availability and low latency over strong consistency - clients see eventually consistent, near-real-time state, which is the right trade-off for dashboards, feeds, and notifications. Fault tolerance comes from redundancy, partition-tolerant streaming, at-least-once delivery with idempotent processing, and graceful degradation (a client reconnects and catches up from the current state).
How do you design a highly scalable real-time system that pushes live updates to millions of clients?
I split it into two scaling problems - ingesting/processing a high-volume event stream, and pushing updates to a huge number of persistent client connections - and design each with the right technology, choosing availability and low latency over strong consistency because near-real-time, eventually consistent state is what these systems actually need. On the event side, sources feed a high-throughput streaming platform (Event Hubs or Kafka) that ingests massive volumes durably and partitioned; stream processing then aggregates, filters, enriches, and windows the events, preserving per-key ordering via partitions and using at-least-once delivery with idempotent processing so faults don’t lose or corrupt data, and I maintain materialized views of current state so a newly connecting client can be brought up to date immediately. On the client-push side, which inverts the normal request/response model, I use a real-time gateway based on WebSockets (for bidirectional/interactive) or Server-Sent Events (one-way streaming), abstracted in .NET by SignalR; to scale persistent connections across many server instances I use a backplane (Redis) so updates fan out to the right subscribers regardless of which server holds a given connection, and I scale the gateway horizontally to handle millions of concurrent connections. A pub/sub layer connects processing to the gateway so processed events are dispatched to interested clients. For consistency I deliberately favor availability and low latency - clients see eventually consistent, near-real-time updates - which is the correct trade-off for dashboards, feeds, and notifications where a tiny staleness is fine but downtime or lag is not. For fault tolerance I use redundancy, partition- tolerant streaming, idempotent at-least-once processing, and graceful degradation: if a client disconnects it reconnects and catches up from the current materialized state rather than needing every missed event replayed. I keep it observable, monitoring lag and connection health, and I load-test at target connection and event scale. The architectural through-line I’d stress is treating real-time as two distinct scalable pipelines - stream ingestion/processing and connection/push - joined by pub/sub, with eventual consistency and fault-tolerant, idempotent processing, so the system delivers low-latency live updates to enormous numbers of clients while staying resilient.
Why do real-time systems favor eventual consistency, and when would that be unacceptable?
Real-time systems favor eventual consistency because their goal is low-latency availability of near-current information to many clients, and insisting on strong consistency across a distributed, high-throughput, widely-connected system would add coordination latency and reduce availability - directly undermining the “real-time” and “always-on” properties that are the whole point. For the typical real-time use cases - live dashboards, activity feeds, notifications, presence, collaborative cursors, IoT telemetry - a client seeing state that is a fraction of a second stale, or different clients being momentarily slightly out of sync, is perfectly acceptable and unnoticeable, whereas lag or downtime is very noticeable and harmful. So the CAP/PACELC trade-off is resolved toward availability and low latency, with clients converging to the current state quickly, which also lets the system scale and tolerate partitions gracefully (a client reconnects and catches up). That said, eventual consistency is unacceptable when a real-time update drives a decision or action where seeing stale or conflicting state causes real harm or incorrectness - for example, real-time trading or order matching where acting on stale prices loses money and ordering/consistency is critical; real-time inventory at the moment of a purchase decision where staleness causes overselling; safety-critical control systems where acting on outdated sensor state is dangerous; or financial balance checks authorizing a transaction. In those cases the specific decision needs strong consistency even though the surrounding system is real-time, so I isolate that critical decision to a strongly consistent component (as we do with the ledger in banking or atomic inventory reservation in e-commerce) while the broader real-time distribution stays eventually consistent. The principle I’d articulate is that consistency is chosen per concern: real-timedistribution and displayof information overwhelmingly favors eventual consistency for latency and availability, but any real-timedecision or transactionwhere correctness of the latest value is essential must be carved out and made strongly consistent - so the answer is that eventual consistency is the right default for real-time systems precisely because their value is timely availability, but it’s unacceptable exactly where a stale value would cause an incorrect or harmful action, which I handle by keeping those critical paths strongly consistent within an otherwise real-time, eventually-consistent architecture.
7.6 Real-Time Banking Scenario
A bank uses this architecture for live transaction notifications, real-time fraud alerts, account updates, and market data. Transaction events stream through Event Hubs and stream processing, which pushes updates via a SignalR gateway (Redis backplane) to customers’ apps in real time. The distribution is eventually consistent and highly available - a customer seeing a notification a fraction of a second late is fine - while the underlying money movement stays strongly consistent in the ledger. Reconnecting clients catch up from the current state, and idempotent at-least-once processing ensures no alert is lost.
Chapter Revision Notes
- Real-time systems are two scaling problems: stream ingestion/processing and client push.
- Push with WebSockets/SSE (SignalR) and a Redis backplane to scale persistent connections.
- Process high-volume streams (Event Hubs/Kafka) with per-key ordering and idempotent at-least-once.
- Favor eventual consistency for availability and low latency - the right default for real-time distribution.
- Carve out strongly consistent components for real-time decisions where staleness would cause harm.