kpumuk opened a new pull request, #3275:
URL: https://github.com/apache/thrift/pull/3275

   <!-- Explain the changes in the pull request below: -->
   
   Implemented lingering the same way C++ library handles it:
   
   * completely disabled for the server 
https://github.com/apache/thrift/blob/master/lib/cpp/src/thrift/transport/TServerSocket.cpp#L335-L342
   * enabled for the client but with timeout of 0 seconds 
https://github.com/apache/thrift/blob/master/lib/cpp/src/thrift/transport/TSocket.cpp#L101-L102
   
   Lingering for the client can be configured:
   
   ```ruby
   socket = Thrift::Socket.new('localhost', port)
   # Disable lingering
   socket.linger(false, 0)
   # Enable lingering with timeout 10 seconds
   socket.linger(true, 10)
   ```
   
   ## Benchmark
   
   Before:
   
   ```
   THRIFT_NUM_CALLS=1 THRIFT_NUM_CLIENTS=1000 
THRIFT_SERVER=Thrift::ThreadPoolServer ruby benchmark/benchmark.rb; netstat -n 
| wc -l
   Starting server...
   Spawning benchmark processes...
   Collecting output...
   Translating output...
   Analyzing output...
   
   Server class:        Thrift::ThreadPoolServer
   Server interpreter:  ruby
   Client interpreter:  ruby
   Socket class:        Thrift::Socket
   Number of processes: 40
   Clients per process: 1000
   Calls per client:    1
   Using fastthread:    no
   
   Connection failures:               0
   Connection errors:                 0
   Average time per call:             0.0080 seconds
   Average time per client (1 calls): 0.0082 seconds
   Total time for all calls:          319.6949 seconds
   Real time for benchmarking:        9.1044 seconds
   Shortest call time:                0.0001 seconds
   Longest call time:                 0.0229 seconds
   Shortest client time (1 calls):    0.0003 seconds
   Longest client time (1 calls):     0.2283 seconds
   
   ====> 13714 open sockets afterwards in TIME_WAIT status
   ```
   
   After:
   
   ```
   $ THRIFT_NUM_CALLS=1 THRIFT_NUM_CLIENTS=1000 
THRIFT_SERVER=Thrift::ThreadPoolServer ruby benchmark/benchmark.rb; netstat -n 
| wc -l
   Starting server...
   Spawning benchmark processes...
   Collecting output...
   Translating output...
   Analyzing output...
   
   Server class:        Thrift::ThreadPoolServer
   Server interpreter:  ruby
   Client interpreter:  ruby
   Socket class:        Thrift::Socket
   Number of processes: 40
   Clients per process: 1000
   Calls per client:    1
   Using fastthread:    no
   
   Connection failures:               0
   Connection errors:                 0
   Average time per call:             0.0083 seconds
   Average time per client (1 calls): 0.0084 seconds
   Total time for all calls:          330.7904 seconds
   Real time for benchmarking:        9.2939 seconds
   Shortest call time:                0.0001 seconds
   Longest call time:                 0.0245 seconds
   Shortest client time (1 calls):    0.0003 seconds
   Longest client time (1 calls):     0.2390 seconds
   
   ====> 4 open sockets afterwards, ~85 in the process
   ```
   
   <!-- We recommend you review the checklist/tips before submitting a pull 
request. -->
   
   - [x] Did you create an [Apache 
Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket? 
[THRIFT-5914](https://issues.apache.org/jira/browse/THRIFT-5914)
   - [x] If a ticket exists: Does your pull request title follow the pattern 
"THRIFT-NNNN: describe my issue"?
   - [x] Did you squash your changes to a single commit?  (not required, but 
preferred)
   - [x] Did you do your best to avoid breaking changes?  If one was needed, 
did you label the Jira ticket with "Breaking-Change"?
   - [ ] If your change does not involve any code, include `[skip ci]` anywhere 
in the commit message to free up build resources.
   
   <!--
     The Contributing Guide at:
     https://github.com/apache/thrift/blob/master/CONTRIBUTING.md
     has more details and tips for committing properly.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to