Performance: Socket.io overview
MEDIUM IMPACT
Socket.io affects real-time communication speed and responsiveness between client and server, impacting interaction latency and network load.
io.on('connection', socket => { socket.on('message', msg => { socket.broadcast.emit('message', msg); }); });
io.on('connection', socket => { socket.on('message', msg => { io.emit('message', msg); }); });
| Pattern | Network Usage | CPU Load | Latency Impact | Verdict |
|---|---|---|---|---|
| Broadcast to all clients including sender | High | High | Higher latency due to redundant messages | [X] Bad |
| Broadcast to all except sender | Medium | Medium | Lower latency with less redundant traffic | [OK] Good |