Performance: Room and namespace concepts
MEDIUM IMPACT
This concept affects how efficiently the server manages socket connections and message broadcasting, impacting interaction responsiveness and server load.
io.of('/chat').to('room1').emit('message', data); // sends only to clients in 'room1' room within '/chat' namespace
io.emit('message', data); // sends to all connected clients regardless of group| Pattern | Server CPU Usage | Network Traffic | Client Processing | Verdict |
|---|---|---|---|---|
| Broadcast to all clients | High | High | High | [X] Bad |
| Broadcast to specific room | Low | Low | Low | [OK] Good |
| Single namespace for all events | Medium | Medium | Medium | [!] OK |
| Separate namespaces per feature | Low | Low | Low | [OK] Good |