NexusNode is a high-performance, horizontally scalable WebSocket message broker built with Node.js. It implements a distributed Pub/Sub architecture, allowing thousands of concurrent clients to communicate across a cluster of server nodes with sub-millisecond latency.
- Distributed Pub/Sub: Seamless message routing across multiple server instances using Redis-backed synchronization.
- Topic-Based Routing: Clients can subscribe to specific channels (e.g.,
orders.created,chat.room.5) for granular data streams. - Horizontal Scalability: Add or remove nodes dynamically; the system utilizes a stateless gateway model to handle traffic spikes.
- Fault Tolerance: Integrated heartbeat monitoring and automated cleanup of stale client connections.
- Observability: High-speed structured JSON logging powered by
Pinofor production-grade monitoring.
NexusNode operates as a cluster of independent gateway nodes connected via a common Redis Backbone.
- Ingress: A client connects to any available node via WebSockets and sends a
SUBSCRIBEpacket. - Local Registration: The node stores the client reference in a local
Mapfor zero-latency lookups. - Cross-Node Propagation: When a message is
PUBLISHEDon Node A, it is instantly broadcast to the Redis layer. - Egress: All other nodes (Node B, C, etc.) receive the Redis event and dispatch it to their locally connected subscribers.
| Component | Technology | Purpose |
|---|---|---|
| Runtime | Node.js (LTS) | Non-blocking event loop for I/O |
| WebSockets | ws library |
Native, high-speed socket handling |
| Message Bus | Redis | Cross-cluster state synchronization |
| Logging | Pino | High-performance structured logging |
| Containerization | Docker | Environment parity and easy scaling |
Since NexusNode is built to run in a cluster, the easiest way to start it is via Docker Compose:
- Clone the repository:
git clone https://github.com/nexus-labs/nexus-node.git
cd nexus-node
- Spin up the cluster (3 Nodes + Redis):
docker-compose up --build
- Test the connection:
Connect any WebSocket client (like Postman or a browser console) to
ws://localhost:3001orws://localhost:3002.
{
"action": "SUBSCRIBE",
"topic": "market_updates"
}
{
"action": "PUBLISH",
"topic": "market_updates",
"data": {
"symbol": "BTC/USD",
"price": 64000
}
}
- Auth Layer: JWT-based authentication for private topics.
- Persistence: Optional MongoDB adapter to store "missed" messages for offline clients.
- Admin Dashboard: Real-time visualization of cluster health and connected clients.
- Binary Support: Protocol Buffers support for lower bandwidth consumption.
Distributed under the MIT License. See LICENSE for more information.