Sergey Orsik.dev
← projects

// case study

Realtime Event Pipeline

Product needed sub-100ms fan-out to thousands of concurrent WebSocket clients from a single write path.

Role

Backend engineer — streaming architecture, Redis pub/sub, connection layer

Stack

Node.jsWebSocketsRedisKafkaKubernetes

Architecture

Highlights

  • Write path: API → Kafka → consumers → Redis pub/sub → edge nodes
  • Connection registry with heartbeat and graceful drain on deploy

Architecture

Events enter Kafka for durability, then fan out through Redis channels partitioned by room ID. Edge pods subscribe only to channels with local connections.

Deploy strategy: drain connections with GOAWAY before pod termination — zero message loss in practice.

Engineering details

  1. Backpressure — slow consumers drop to catch-up mode with snapshot resync.
  2. Ordering — partition key = roomId guarantees per-room order.
  3. Observability — lag metrics per consumer group + connection count per pod.