Designing a real-time, low-latency WebSocket gateway with multi-room state synchronization using Redis.
Founding Engineer project targeting high concurrency, real-time sync, or custom system designs.
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.
I architected a stateless, event-driven WebSocket gateway using Node.js, Firebase, and Redis:
ws driver for lightweight, high-performance bi-directional sockets.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.
Screenshots, dashboard metrics, and recorded event videos proving the system running in real-time.

QuizPulse live mobile client interface during a competitive trivia round.

Dashboard showing active rooms, player counts, and gateway stats.
Live event recording showing the public actively using QuizPulse in real-time.