01The problem
Every device keeps a socket open to the backend for commands and status updates. At six figures of devices, a short network blip means all of them try to reconnect in the same second, and any message lost during that window has to be delivered later.
02Approach
I built the device layer on NestJS with Socket.io and kept device state in MongoDB. Events go through a queue with at-least-once delivery, so a slow consumer delays a message instead of losing it.
The original backend was one service. We split it into NestJS services on Docker and Kubernetes, which kept one slow path from dragging the rest down and cut p95 latency by about 40%.
03Results
The platform holds more than 100,000 concurrent connections and moves millions of events a day. The demo below is a small simulation of the reconnect problem, built for this site. It isn't production code.
FAQ
How do you keep that many WebSocket connections reliable?
Can you build a real-time system like this for me?
Need something like this?
I'm Ahmed Mamdouh — 10+ years building systems like Real-time device platform. Scoped in one call.