TCP_NODELAYTCP_NODELAY turns off Nagle's algorithm. In Node, you set it with socket.setNoDelay(true).
Nagle's algorithm holds back small segments while earlier data is still unacknowledged. It does this so it can combine them into one bigger segment. The receiver may also use a delayed ACK: it waits a little before it acknowledges data. Together, these two waits can add a noticeable delay.SO_KEEPALIVE is a tempting wrong answer. It turns on probes for idle connections. It has nothing to do with send delays.
Read more