Skip to Content
Back to Projects
600 CCU · 1.12s Latency

QuizPulse: Live Interactive Quizzes

Designing a real-time, low-latency WebSocket gateway with multi-room state synchronization using Redis.

Technologies Used

FirebaseTypeScriptWebSocketsRedis Pub/SubReact.jsDocker

Scope & Context

Founding Engineer project targeting high concurrency, real-time sync, or custom system designs.

Codebase Link

Private repo · Available on request

The Problem

Competitive, multi-room quiz games require instantaneous question delivery and leaderboard updates. Conventional HTTP long-polling drains server resources, causes immense database strain, and exhibits variable latency of up to 4 seconds, which completely breaks the synchronization of live games.

When hundreds of clients connect simultaneously, a traditional thread-per-request architecture falls flat, rapidly exhausting socket descriptors and memory limits.

The Solution & Architecture

I architected a stateless, event-driven WebSocket gateway using Node.js, Firebase, and Redis:

  • Event-Driven Gateway: Built on top of WebSocket Gateways utilizing the underlying ws driver for lightweight, high-performance bi-directional sockets.
  • State Sync via Redis Pub/Sub: Deployed stateless API nodes and synchronized quiz state across instances using Redis Pub/Sub channels. This allows nodes to scale horizontally without losing connection details.
  • Memory-Efficient Cache: Stored active quiz session states in Redis memory rather than query-heavy MongoDB tables, resolving database read/write limits.

Engineering Deep Dive

During stress testing, the server encountered severe Garbage Collection (GC) pauses that spiked latency from 50ms to over 3 seconds. The server eventually crashed with Out Of Memory (OOM) errors.

I diagnosed the issue by connecting Chrome DevTools to the Node.js process and analyzing heap snapshots under simulated load. The heap logs revealed that socket client instances were not being garbage collected when users disconnected. The root cause was dangling event listeners in our custom auth validation middleware.

I resolved the leak by refactoring the connection manager to use a strict lifecycle container, replacing arrays with weakly held maps (WeakMap), and explicitly tearing down all listeners on the disconnect event, which flattened memory usage and maintained a clean, stable heap allocation.

Related Reading: To learn more about optimizing package directories and managing monorepo workspace configurations under Node.js, check out my deep dive: npm vs. Yarn vs. pnpm: The Ultimate Package Manager Comparison.

Quantifiable Metrics

1

600 CCU Stable

Supported 600 concurrent connections across multiple active rooms with zero connection drops.
2

1.12s Sync Latency

Reduced average client-to-client event delivery latency to a stable 1.12 seconds.
3

50% CPU Savings

Reduced server CPU consumption by 50% through Redis memory caching of active game states.
4

Memory Leak Fixed

Resolved critical socket memory leaks, ensuring a flat heap baseline under 24-hour continuous load.

Visual Showcase

Screenshots, dashboard metrics, and recorded event videos proving the system running in real-time.

QuizPulse live mobile client interface during a competitive trivia round.

QuizPulse live mobile client interface during a competitive trivia round.

Dashboard showing active rooms, player counts, and gateway stats.

Dashboard showing active rooms, player counts, and gateway stats.

Live event recording showing the public actively using QuizPulse in real-time.