Backend · Production
Real-Time Chat Platform
A messaging system that keeps sockets and business logic apart.
85%
Query reduction
< 28ms
Message latency
The problem
Chat systems tend to degrade quietly: as concurrent connections grow, a monolithic server starts mixing socket bookkeeping with database-heavy business logic, and both get slower.
What I did
I split the system into a dedicated realtime gateway that only manages socket connections, and a set of stateless services (users, friends, chat) that it talks to over internal calls. That let the socket tier and the business logic scale — and fail — independently.
- WebSocket gateway kept fully separate from the REST/GraphQL API
- DataLoader batching cut conversation-list queries by roughly 85%
- MySQL schema built around cursor pagination from day one
What I'd take forward
- Long-lived connections and CPU-heavy request handling don't belong in the same process.
- DataLoader is one of the highest-leverage additions you can make to a relational API layer.
Built with
FastifySocket.IOMySQLDataLoader