axum
axum copied to clipboard
Set tcp nodelay on sockets
- [x] I have looked for existing issues (including closed) about this
Feature Request
Motivation
Currently axum
does not set tcp-nodelay on accepted connections.
As demonstrated in this issue: https://github.com/hyperium/hyper/issues/3269 this default behaviour can heavily degrade performance in some use cases.
Proposal
Add some way to set TCP_NODELAY
on the accepted connections (via TcpStream::set_nodelay
).
Variants
- Make it the default behaviour for
axum::serve
by just setting it on each accepted connection - Add a function to
axum::serve::Serve<>
(likegraceful_shutdown
) of which the usage could look something like this:
axum::serve(...).set_nodelay(true).await
Some Notes/Questions
As far as I understood you want to keep this part of axum
relatively simple and prefer to refer to hyper-util
for more complex tasks. However, this would be a relatively small change (I can create a PR if you want) so it doesn't add much code complexity and can give huge performance boosts.
So I guess questions:
- Do you want this at all?
- If you do: What would you like for an interface?