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

Use TCP_NODELAY on TLS sockets to speed up the TLS handshake. #1214

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

gthess
Copy link
Member

@gthess gthess commented Jan 10, 2025

Setting TCP_NODELAY on TLS sockets speeds up the TLS handshake.
Also noted on https://docs.openssl.org/3.4/man3/SSL_connect/#notes.

It was observed that during the handshake the server waits before sending more handshake data for the client ACK (Nagle's algorithm), which is delayed because the client waits for more data before ACKing (delayed ACK).

Old versions of OSes don't seem to experience the handshake delay (e.g., Ubuntu 20.04).
Tested with the same compiled versions of Unbound and OpenSSL across OS versions.
Maybe something changed in the kernel (or the kernel configuration) but couldn't pinpoint anything in particular.

Fixes #1045, #1185, #1202.

@gthess gthess requested a review from wcawijngaards January 10, 2025 11:25
@gthess gthess self-assigned this Jan 10, 2025
Copy link
Member

@wcawijngaards wcawijngaards left a comment

Choose a reason for hiding this comment

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

Better speed on the handshake may improved DNS lookup latency. The code looks fine, for setting the nodelay option.

@gthess
Copy link
Member Author

gthess commented Jan 10, 2025

Thanks!

@gthess gthess merged commit 7e4f7ec into master Jan 10, 2025
1 check passed
gthess added a commit that referenced this pull request Jan 10, 2025
- Merge #1214: Use TCP_NODELAY on TLS sockets to speed up the TLS
  handshake.
@gthess gthess deleted the bugfix/tls-handshake branch January 10, 2025 12:55
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.

Low Throughput Issue with unbound DNS over TLS on Ubuntu 22.04
2 participants