Skip to content

perf: tune TCP and HTTP/1 buffering - #1590

Open
robjtede wants to merge 2 commits into
svenstaro:masterfrom
robjtede:perf/connection-tuning
Open

robjtede wants to merge 2 commits into
svenstaro:masterfrom
robjtede:perf/connection-tuning

Conversation

@robjtede

@robjtede robjtede commented Nov 3, 2026

Copy link
Copy Markdown

Enable TCP_NODELAY and a 256 KiB HTTP/1 write buffer. Require Actix Web 4.14.

Trixie ARM64 Docker loopback; median of five 5-second runs. Settings tested separately.

Setting File / connections Before req/s After req/s Gain
TCP_NODELAY 1 KiB / 1 23.5 8,317 354×
TCP_NODELAY 1 KiB / 32 763 58,093 76×
256 KiB HTTP buffer 1 MiB / 8 6,112 6,638 8.6%

@svenstaro

svenstaro commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Huh nice, really makes you think why this isn't upstream default.

EDIT: Hang on, you are upstream! Haha. So, how about you make this default?

@robjtede

robjtede commented Nov 3, 2026

Copy link
Copy Markdown
Author

We didn't decide whether to do it in v4.x yet. But it will for sure be in v5. We're seeing varying scales of speed-ups from 1% to the eye watering 300x improvement seen here depending on setup and benchmark quality.

@robjtede

robjtede commented Nov 3, 2026 •

Copy link
Copy Markdown
Author

To be clear, this benchmark are by no means well-crafted, using only a constrained Docker-on-macOS setup, so the speed-ups are probably less than your users will actually see. But plausibly a tiny Linux box on a crappy VPS will benefit most.

Comment thread src/main.rs
Comment on lines +272 to +273
.tcp_nodelay(true)
.h1_write_buffer_size(256 * 1024);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a tiny comment here as to why?

@svenstaro

Copy link
Copy Markdown
Owner

Please rebase. I just made master happy.

@robjtede
robjtede force-pushed the perf/connection-tuning branch from 1c6de9e to 4539436 Compare November 3, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants