Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set tcp nodelay on sockets #2521

Closed
1 task done
liss-h opened this issue Jan 16, 2024 · 3 comments · Fixed by #2653
Closed
1 task done

Set tcp nodelay on sockets #2521

liss-h opened this issue Jan 16, 2024 · 3 comments · Fixed by #2653

Comments

@liss-h
Copy link
Contributor

liss-h commented Jan 16, 2024

  • 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: hyperium/hyper#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

  1. Make it the default behaviour for axum::serve by just setting it on each accepted connection
  2. Add a function to axum::serve::Serve<> (like graceful_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:

  1. Do you want this at all?
  2. If you do: What would you like for an interface?
@nylonicious
Copy link
Contributor

#2479 is going to let you set settings for the accepted connections before handing them over. However it's a breaking change so unfortunately you will need to wait for 0.8.

@x1957
Copy link
Sponsor

x1957 commented Mar 9, 2024

I've also encountered this issue, it's very important!thanks

@jplatte
Copy link
Member

jplatte commented Mar 14, 2024

A PR for a tcp_nodelay method on Serve would be appreciated. Then for 0.8 we can see if it makes sense to remove again because of #2479.

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 a pull request may close this issue.

4 participants