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 #551

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

bitianyuan123
Copy link

@bitianyuan123 bitianyuan123 commented Jan 14, 2025

Submit the tcpnodelay Configuration Switch

Performance Optimization:

The server sends the SSH2_MSG_CHANNEL_OPEN_CONFIRMATION message immediately after sending the public key information (SSH2_MSG_GLOBAL_REQUEST).However, the client does not need to send any message (the SSH2_MSG_CHANNEL_Open and SSH2_MSG_GLOBAL_REQUEST messages have been sent). Therefore, after the client receives the message, the kernel waits for 40 ms to send an ACK message(due to the Nagle's algorithm). As a result, the server kernel needs to wait until the ACK with a delay of 40 ms is received when sending SSH2_MSG_CHANNEL_OPEN_CONFIRMATION.

In fact, the client and server set the socket status to TCP_NODELAY after the channel is established (received).

We will set TCP_NODELAY in advance until after authentication is complete.
We can also add a configuration option. When users are sensitive to performance, TCP_NODELAY is set after the TCP connection between the server and client is established.

This modification results in a 20% performance improvement in frequent short-connection environments.
An SSH connection takes about 200 ms. Setting TCP_NODELAY can optimize the performance of 40 ms.

@bitianyuan123
Copy link
Author

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.

1 participant