Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Accurate proof that Ruby is closer to the bear metal than Node.js
#!/usr/bin/env bash
siege -c 10 -b -t 30s http://localhost:9393
#!/usr/bin/env bash
siege -c 10 -b -t 30s http://localhost:9292
require 'rack'
class Application
def call(env)
return [200, {'Content-Type' => 'text/plain'}, ['Hello world']]
end
end
run Application.new
var http = require('http');
var server = http.createServer(function(request, response)
{
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello world');
});
server.listen(9393, '0.0.0.0');
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]:
** SIEGE 3.0.5
** Preparing 10 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 158092 hits
Availability: 100.00 %
Elapsed time: 29.06 secs
Data transferred: 1.66 MB
Response time: 0.00 secs
Transaction rate: 5440.19 trans/sec
Throughput: 0.06 MB/sec
Concurrency: 9.90
Successful transactions: 158092
Failed transactions: 0
Longest transaction: 0.02
Shortest transaction: 0.00
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]:
** SIEGE 3.0.5
** Preparing 10 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 222639 hits
Availability: 100.00 %
Elapsed time: 29.91 secs
Data transferred: 2.34 MB
Response time: 0.00 secs
Transaction rate: 7443.63 trans/sec
Throughput: 0.08 MB/sec
Concurrency: 9.88
Successful transactions: 222639
Failed transactions: 0
Longest transaction: 0.02
Shortest transaction: 0.00
rubinius 2.2.6.n73 (2.1.0 f3c12adf 2014-03-14 JI) [x86_64-linux-gnu]:
** SIEGE 3.0.5
** Preparing 10 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 103199 hits
Availability: 100.00 %
Elapsed time: 29.28 secs
Data transferred: 1.08 MB
Response time: 0.00 secs
Transaction rate: 3524.56 trans/sec
Throughput: 0.04 MB/sec
Concurrency: 9.94
Successful transactions: 103199
Failed transactions: 0
Longest transaction: 0.11
Shortest transaction: 0.00
jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on OpenJDK 64-Bit Server VM 1.7.0_51-b31 [linux-amd64]:
** SIEGE 3.0.5
** Preparing 10 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 180525 hits
Availability: 100.00 %
Elapsed time: 29.82 secs
Data transferred: 1.89 MB
Response time: 0.00 secs
Transaction rate: 6053.82 trans/sec
Throughput: 0.06 MB/sec
Concurrency: 9.90
Successful transactions: 180525
Failed transactions: 0
Longest transaction: 0.06
Shortest transaction: 0.00
Node.js v0.10.26:
** SIEGE 3.0.5
** Preparing 10 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 190550 hits
Availability: 100.00 %
Elapsed time: 29.91 secs
Data transferred: 2.00 MB
Response time: 0.00 secs
Transaction rate: 6370.78 trans/sec
Throughput: 0.07 MB/sec
Concurrency: 9.92
Successful transactions: 190550
Failed transactions: 0
Longest transaction: 0.02
Shortest transaction: 0.00
#!/usr/bin/env bash
echo 'Node version:'
node --version
node node.js
#!/usr/bin/env bash
echo 'Ruby version:'
ruby --version
export RACK_ENV=none
puma -e none -p 9292 -t 64:128
@ernie

This comment has been minimized.

Copy link

ernie commented Mar 14, 2014

I hope nobody gets bitten, getting this close to metal bears.

@benlangfeld

This comment has been minimized.

Copy link

benlangfeld commented Mar 15, 2014

You would have got better results on JRuby if you had primed the JVM for longer than your 30s run. Rubinius might benefit from some priming also. Running these over a period of tens of minutes or a few hours would give slightly more realistic results.

@bbrowning

This comment has been minimized.

Copy link

bbrowning commented Mar 17, 2014

I feel like you're essentially recreating the plaintext test of the techempower benchmarks but with less warmup time and a slower server choice for JRuby. Here's a link to their latest published results, filtered to show only nodejs, rack-jruby, and rack-ruby.

http://www.techempower.com/benchmarks/#section=data-r8&hw=i7&test=plaintext&f=g0-0-0

In case you don't follow the link or it breaks: rack-jruby 269k req/s, nodejs 80k req/s, and rack-ruby 69k req/s.

The JSON parsing results at http://www.techempower.com/benchmarks/#section=data-r8&hw=i7&test=json&f=g0-0-0 are similar, with rack-jruby at 186k req/s, nodejs at 71k req/s, and rack-ruby at 61k req/s.

They don't have Rubinius in their test suite, but would probably be open to adding it for future rounds. You can try to recreate the jruby/ruby/node results by replacing puma with the 'torqbox' gem for jruby and unicorn behind nginx for ruby.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.