Skip to content

Instantly share code, notes, and snippets.

@ddossot
Last active February 3, 2016 21:30
Show Gist options
  • Save ddossot/d3194836fc17993c42aa to your computer and use it in GitHub Desktop.
Save ddossot/d3194836fc17993c42aa to your computer and use it in GitHub Desktop.
Ruby/jRuby Rack application face-off

Simple Rack application

  • Grape middleware
  • MySQL DB
  • ab -n 2000 -c 20

Running on jRuby 1.7.14 / Vertx 2.1.1 / JDK8

  • Java HotSpot(TM) 64-Bit Server VM (build 25.20-b22, mixed mode)
Percentage of the requests served within a certain time (ms)
  50%    175
  66%    203
  75%    226
  80%    246
  90%    308
  95%    371
  98%    438
  99%    480
 100%    583 (longest request)

Running on jRuby 1.7.14 / Puma 2.9.0 / JDK8

  • Java HotSpot(TM) 64-Bit Server VM (build 25.20-b22, mixed mode)
Percentage of the requests served within a certain time (ms)
  50%    207
  66%    231
  75%    247
  80%    257
  90%    288
  95%    308
  98%    343
  99%    363
 100%    467 (longest request)

Running on Ruby MRI 2.1.2 / Passenger / Nginx

  • ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
Percentage of the requests served within a certain time (ms)
  50%     30
  66%     32
  75%     34
  80%     36
  90%     40
  95%     47
  98%     80
  99%    108
 100%    298 (longest request)

Non-Rack Implementations

Running on jRuby 1.7.14 / Vertx 2.1.1 / JDK8

  • Java HotSpot(TM) 64-Bit Server VM (build 25.20-b22, mixed mode)
  • No gem used, only jars (JDBC, DBCP)
  • Pure Vert.x HTTP, no Rack adapter, no Grape
Percentage of the requests served within a certain time (ms)
  50%      4
  66%      6
  75%      7
  80%      8
  90%     12
  95%     17
  98%     23
  99%     27
 100%     32 (longest request)

Non-Ruby Implementations

Implementations that perform the exact same SQL query and render the same JSON object as a result to the tested HTTP GET operation.

Running on Scala 2.10 / Vertx 2.1.1 / JDK8

  • Java HotSpot(TM) 64-Bit Server VM (build 25.20-b22, mixed mode)
  • Using Yoke and Jersey middlewares (i.e. some overhead on plain Vert.x HTTP)
  • Using Jackson JSON serializer
Percentage of the requests served within a certain time (ms)
  50%      4
  66%      5
  75%      6
  80%      7
  90%      8
  95%      9
  98%     11
  99%     13
 100%     17 (longest request)
@lucasallan
Copy link

Hey I did some tests here, this what I found:

With Grape:

Percentage of the requests served within a certain time (ms)
  50%    175
  66%    196
  75%    213
  80%    224
  90%    256
  95%    282
  98%    314
  99%    337
 100%    451 (longest request)

Same request, without Grape:

Percentage of the requests served within a certain time (ms)
  50%     55
  66%     78
  75%     93
  80%    104
  90%    137
  95%    167
  98%    203
  99%    231
 100%    334 (longest request)

Looks like there is a performance issue with activerecord-jdbcmysql-adapter or active_record. I have seen people complaining about it for awhile. I'm still digging into it.

@GrooveStomp
Copy link

@lucasallan That sounds exactly like the problem I ran into where JRuby was 2+ times slower than MRI for a very simple web application.

@ddossot
Copy link
Author

ddossot commented Sep 7, 2014

@lucasallan What if you keep Grape but replace ActiveRecord with straight JDBC?

@lucasallan
Copy link

@GrooveStomp Yes, I was trying to remember who told me that and was you. @ddossot Good idea, I'll give it a shot.

@headius
Copy link

headius commented Jan 15, 2015

I would like to see the application, so we can investigate why performance is below MRI. As far as I know/remember nobody ever reported this to us (JRuby team).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment