Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable TCP_NODELAY for all synchronous sockets.
The widely documented poor interaction between the Nagle algorithm and TCP's delayed ACK feature, when making short successive writes, leads to unnecessary delays (around 50ms on Linux). This happens in httpcore whenever a POST request is made, since the headers and body are sent as two separate calls. The TCP_NODELAY option can be enabled to disable Nagle's algorithm, and therefore avoid this delay. The option is already enabled by default for all asyncio and Trio sockets. It is also enabled by CPython's http.client module (which urllib and requests use) and by many high-level HTTP libraries found in other languages, including libcurl, Java's Netty, Rust's reqwest and Go's standard library, to name a few.
- Loading branch information