Performance: Broadcasting messages
Broadcasting messages affects the responsiveness and scalability of real-time features by impacting server load and network traffic.
server.emit('update', data);for (const client of clients) { client.emit('update', data); }
| Pattern | Server Event Loop | Network Calls | Client Handling | Verdict |
|---|---|---|---|---|
| Per-client emit | High (N emits) | High (N sends) | Normal | [X] Bad |
| Server broadcast emit | Low (1 emit) | Low (1 send) | Normal | [OK] Good |
this.server.emit('notify', { message: 'Hello' });this.server.emit('chat', message)message is undefined.Pass the test and this pattern moves unknown