http-rs / http-rs/async-h1

Server response sending triggers Nagle's algorithm/delayed ACK interaction

Open
#199 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
166
Forks
49
PR merge metrics
No merged PRs in 30d

Description

The way the `async-h1` encoder streams the HTTP response head and body to the given `io: Write` causes the head and body to be written to the underlying socket as separate calls to `send`, causing them to be sent as separate TCP segments.

If we're handling more than one HTTP request from the same `io` that means that we're doing two sends and then a read. This I/O pattern triggers a bad interaction between Nagle's algorithm and delayed ACK where the read can take up to 500 milliseconds. (On Linux this is 40 milliseconds.)

A work-around for this is to enable `TCP_NODELAY` to disable Nagle's algorithm, but we shouldn't really be sending undersized TCP segment unnecessarily.

Contributor guide

Open the contributing guide

Research direction

Start by locating the async-h1 encoder responsible for streaming the HTTP response head and body through the given io::Write. Trace how those writes reach the underlying socket and inspect existing tests around response encoding. Done means the response no longer causes the head and body to be sent as separate undersized TCP segments, without requiring TCP_NODELAY.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.