Lesson 8 : Real-time Streaming Control Plane

Hands On FullStack Development Course with Infrastructure Management Product implementation ~10 min read 60 min hands-on

Lesson 8: Real-time Streaming Control Plane

If you have ever watched a Datadog dashboard update live, or seen PagerDuty fire an alert the second a server crosses a threshold, you have already seen real-time infrastructure monitoring in action. Today you will build that transport layer yourself β€” not as a toy chat app, but as a production-grade streaming control plane called InfraWatch Realtime.

By the end of this lesson you will have a working operator console with live charts, authenticated WebSocket connections, throttled metric delivery, and a reliability lab that measures p99 latency under load. Let us get into it.


What We Are Building

InfraWatch Realtime β€” a production streaming control plane for infrastructure operators:

  1. Connection Hub β€” WebSocket transport with JWT auth, rooms, and reconnection tracking

  2. Data Streams β€” Live metric streaming, alert broadcasting, and throttled delivery

  3. Event Protocol β€” Versioned envelopes, client sync, conflict resolution, offline queue

  4. Performance Layer β€” Redis queuing, bandwidth optimization, circuit breakers

  5. Reliability Lab β€” Load tests, concurrency bursts, and p99 benchmarking

  6. Live Console β€” Real-time charts, connection status, auto-refresh, offline fallback

  7. Operations β€” End-to-end orchestration with graceful degradation and recovery


Core Concept

Real-time infrastructure monitoring is not about pushing raw data faster β€” it is about controlled delivery under load. Datadog Live Processes, PagerDuty incident streams, and Grafana live annotations all share the same pattern: authenticate connections, subscribe to topics, throttle noisy metrics, and degrade gracefully when backends saturate.

The non-obvious insight: the WebSocket is a control channel, not a firehose. Production systems batch, compress, and prioritize β€” critical alerts bypass throttles. When a client disconnects, events queue locally and flush on reconnect with version-based conflict resolution, the same last-write-wins pattern Stripe uses for dashboard state sync.


Where This Fits

Code

Realtime sits downstream of alerts and notifications, providing the live transport layer that powers operator consoles across the platform.


Component Architecture

Think of the backend as air traffic control. It does not fly the planes (collect metrics on every server in your fleet) β€” it routes, prioritizes, and delivers updates to the right screens at the right speed.


Control & Data Flow

  1. Operator UI opens WebSocket to /ws/{client_id}

  2. Client subscribes to metrics_update, alerts_critical, alerts_warning

  3. Background simulator collects psutil metrics every 500ms

  4. StreamManager throttles and batches; critical alerts bypass the queue

  5. Events broadcast to subscribed clients; offline clients queue for reconnect flush

  6. Dashboard polls REST fallback when WebSocket is down


Connection Lifecycle

A connection is never just "on" or "off" in production. It moves through distinct states β€” connecting, streaming, offline, syncing queued events, and degraded when backends are under stress. Your UI should reflect each state so operators know whether they are looking at live data or a cached fallback.


Building Each Layer

The sections below map directly to the seven capabilities listed above. Work through them in order β€” each layer depends on the one before it.

1. Connection Hub

The connection manager (backend/app/services/connection_manager.py) is the front door. Every client that wants live data must pass through it.

What it does:

  • Issues and verifies JWT tokens on WebSocket connect

  • Keeps a registry of every active client and which room they belong to

  • Handles join_room / leave_room with broadcast notifications to other members

  • Tracks reconnection counts and messages-per-second throughput

REST endpoints

WebSocket protocol β€” connect to WS /ws/{client_id}?token=...

Check it works:

bash

You should see active_connections and messages_per_second fields in the response.


2. Data Streams

Once clients are connected, they need something to stream. The StreamManager handles topic subscriptions and delivery pacing.

What it does:

Keep going with the full lesson

The rest of this lesson β€” plus its implementation guide, runnable scripts and source code β€” is included with the course or an All Access plan. Create a free account to start the free lessons in every course.

Already a member? Sign in