Masif Kadapa
← Back to work
00620252024 — Present

Relay · Realtime Sync Engine

A horizontally scalable WebSocket sync engine — presence, live updates, and offline replay for collaborative apps.

RoleIndependent project
Timeline2024 — Present
StackNode.js · TypeScript · WebSocket · Redis · PostgreSQL
Context

Collaborative apps quietly assume realtime — live cursors, shared state, instant notifications. But rolling your own WebSocket layer usually ends in flaky connections, missed messages, and no story for reconnects.

The problem

A naive socket layer has three failure modes: reconnects lose the messages missed while offline, one chatty room can stall the whole process, and scaling out means duplicate or dropped fan-out.

How it was solved
  1. 01

    Designed a connection gateway that keeps state out of the socket — presence and rooms live in Redis.

  2. 02

    Routed events over Redis pub/sub so any node can serve any client and fan-out stays consistent.

  3. 03

    Built an outbox and replay so a client that drops misses nothing; state reconciles on reconnect.

  4. 04

    Added backpressure and per-room limits so a noisy room can't stall the process.

The detail worth mentioning
The socket is just a door. The system lives in Redis — presence, rooms, and an outbox that guarantee a reconnecting client catches up to the exact message it missed.
Outcome

10k+concurrent clients

on a single node — fan-out over Redis pub/sub, replay on reconnect

  • Sustains 10k+ concurrent connections on a single node, scaling out by adding instances.
  • Reconnects reconcile state from the outbox — zero missed updates.
  • Per-room isolation keeps one busy channel from affecting the rest.