Coalescing Small Writes
The Nagle algorithm improves efficiency by combining many small writes into fewer, larger packets. It holds back a tiny segment until the previous data is acknowledged or enough bytes gather to fill a full packet.
The Benefit
Sending one byte in its own packet wastes header space, since the headers can dwarf the payload.
- Nagle waits for an acknowledgment before sending another small segment.
- Meanwhile it collects more bytes to send together.
- This cuts the flood of tiny packets that a chatty sender would otherwise produce.
The Hidden Delay
The trouble appears when it meets delayed acknowledgment, where the receiver waits briefly before replying. The sender waits for an acknowledgment that the receiver is holding back, adding tens of milliseconds to small interactive messages.
For request and reply protocols that send small messages and need low latency, this pairing causes visible stalls, so latency sensitive sockets often disable Nagle.
Key idea
The Nagle algorithm batches small writes to save header overhead, but combined with delayed acknowledgment it can stall small interactive messages, so low latency sockets frequently turn it off.