For those of you unaware of Thrift, it is an open-source language-
agnostic distributed messaging system created by Facebook (and
currently being incubated as an apache project). I recently re-wrote
the ruby libraries, including writing a brand new threaded server. I
also wrote benchmarking code that spawns the server in one processes,
then spawns 40 worker processes that each connect to the server 5
times and send 50 “messages” to the server. This means there’s a max
of 40 concurrent connections, and 200 total connections. It uses
TCPServer/TCPSocket to accomplish this.
Running the benchmark under MRI takes roughly 9 seconds. Here’s some
sample output from the benchmark:
Thrift::NonblockingServer Benchmark (MRI):
Connection failures: 0
Average time per call: 0.0297 seconds
Average time per client (50 calls): 1.4857 seconds
Total time for all calls: 296.8446 seconds
Real time for benchmarking: 9.2467 seconds
Shortest call time: 0.0009 seconds
Longest call time: 0.1499 seconds
Shortest client time (50 calls): 0.0867 seconds
Longest client time (50 calls): 1.9158 seconds
Unfortunately, when I switch to jruby, I see a significant slowdown.
Thrift::NonblockingServer Benchmark (jruby)
Connection failures: 0
Average time per call: 0.0681 seconds
Average time per client (50 calls): 3.4094 seconds
Total time for all calls: 681.3200 seconds
Real time for benchmarking: 18.2711 seconds
Shortest call time: 0.0013 seconds
Longest call time: 2.2829 seconds
Shortest client time (50 calls): 1.2270 seconds
Longest client time (50 calls): 8.1265 seconds
In this run, it took twice as long as MRI to run the benchmark. The
best number I’ve seen is just over 15 seconds, but usually I see
roughly 19 seconds. This is under the exact same environment and load
as the MRI benchmark.
Does anybody have any suggestions to explain this performance issues?
If you wish to try it yourself, you first need a patched version of
jruby. The following two patches need to be applied to jruby 1.1.2 or
jruby svn:
http://jira.codehaus.org/secure/attachment/35101/ChannelStream-readpartial.patch
http://jira.codehaus.org/secure/attachment/35098/jruby-select.patch
Hopefully these patches will be applied to svn trunk tomorrow.
Anyway, once you have that, you can download my own thrift code at
http://github.com/kballard/thrift
Inside the thrift clone (or tarball) you can cd to lib/rb. From there,
run rake benchmark
to test the MRI benchmark and rake benchmark THRIFT_SERVER_INTERPRETER=jruby
to test the jruby benchmark. Note
that when using the jruby benchmark, the worker clients are still run
using MRI. Attempting to run them under jruby doesn’t even work at the
moment.
-Kevin B.
–
Kevin B.
[email protected]
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email