THRIFT-5904: Set TCP_NODELAY on accepted sockets #3243
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request enables
TCP_NODELAYflag on the accepted socket in theServerSockettransport in Ruby.The change brings Ruby server transport to the same level as servers in other languages, for example C++.
Bechmarks
Changing socket flags is an obviously risky operation. There is a good reason for this though: it improves TLS server performance speed up to 13x for some workloads.
Note
Currently benchmark script has several breaking issues:
Fixnumin theBaseProtocol(write_typeandread_type)NonblockingServer, which seem to be incompatible withSSLServerSocketGiven all this, I will be using
ThreadPoolServerfor benchmarking, and a script that has SSL with an elliptic curve cryptography for best performance. I am testing with number of processes set to 4, as Ruby GIL affects how much a single multi-threaded server can process concurrently.Baseline - Non TLS Server
No visible performance difference.
TLS server with multiple requests per connection
Before (server with TLS)
This brings about 3x performance improvement.
TLS server with a single request per connection
The difference is 13x for the total time, and 68x if measured CPU time required to send those messages on all CPUs.
[skip ci]anywhere in the commit message to free up build resources.