Performance: TCP transport
MEDIUM IMPACT
This affects the speed and responsiveness of backend communication between microservices or clients and servers using TCP protocol.
const client = new ClientTCP({ host: 'localhost', port: 3000 });
await client.connect();
const response1 = await client.send('event1', { data1 }).toPromise();
const response2 = await client.send('event2', { data2 }).toPromise();
// reuse client without reconnecting
await client.close();const client = new ClientTCP({ host: 'localhost', port: 3000 });
await client.connect();
const response = await client.send('event', { data }).toPromise();
await client.close();| Pattern | Connection Overhead | Latency per Message | Resource Usage | Verdict |
|---|---|---|---|---|
| Create and close client per message | High (new TCP handshake each time) | High (100-200ms extra) | High CPU and network usage | [X] Bad |
| Reuse persistent client connection | Low (single handshake) | Low (minimal extra latency) | Lower CPU and network usage | [OK] Good |