05
Jan
12

PHP vs. Ruby/JRuby on Rails vs. Grails vs. Java performance comparison

In this write-up I captured my findings about the performance of various frameworks that I was considering for my next project…

Test setup:

  • One MySQL 5.1 table consisting of an ID and 2 string columns, 1000 rows (+5 for warm-up)
  • a simple web application that:
    • reads one record from the table
    • displays record data on a web page in table form
The page is accessed sequentially 5 times to warm up the caches, then 1000 times (timed). The time is captured below.

Test subjects:

  1. PHP 5.3.3 on Apache 2.2.21
  2. Ruby 1.8.7 + Rails 3.1.3 on mongrel 1.1.5
  3. JRuby 1.6.5 (emulating Ruby 1.8.7) + Rails 3.1.3 on mongrel 1.1.5
  4. Grails 2.0.0 (Groovy 1.8.4) on Tomcat 7.0.16
  5. Java 1.7 + Spring 3 on Tomcat 7.0.23

Everything was set to ‘production mode’. Test platform: win32.

Test results:

Framework Time per request
PHP 10.6ms
Ruby/Rails 14.1ms
JRuby/Rails 16.0ms
Grails/Groovy 7.4ms
Java 6.4ms

Java seems to be a clear winner here… too bad it’s by far the slowest of the 5 to develop in! :-[]

p.s. I know my JRuby setup is awkward… I just couldn’t get any sane performance out of it on a Tomcat. The perf I got in this post is the best I could achieve.


8 Responses to “PHP vs. Ruby/JRuby on Rails vs. Grails vs. Java performance comparison”


  1. February 28, 2012 at 7:04 am

    Hi Rusty,

    Thanks for sharing those numbers with the community… Do you have the testing code checked-in somewhere?

    Thanks
    Marcello

    • February 28, 2012 at 12:41 pm

      Nope, sorry. This test was a part of a bigger application. Extracting just the benchmark code would be too much extra effort. But I can publish any portion of the code or configuration, to answer any specific questions.

      – Rusty –

  2. March 22, 2012 at 2:25 pm

    I would rerun the rails benchmarks using the latest version of Ruby – 1.9.3 springs to mind – and I feel you’ll be pleasantly surprised.

  3. October 28, 2012 at 9:39 pm

    it’s really tough to beat the performance and speed of Java. Groovy, Clojure and Scala would be better for Java benchmarking comparisons. IMHO

  4. 5 Feras
    May 14, 2013 at 8:19 pm

    Update:
    You can use php with APC and apc.stat turned on, that will result in JAVA like performance on the PHP code itself.
    Grails 2.2 now supports Groovy 2, which has @CompileStatic and @TypeChecked, again leading to Java like performance.

  5. September 7, 2013 at 5:37 am

    Its a tough call for PHP, since fast_cgi, or mod_php and apache / nginx and so on. But I think you totally got the average setup.

  6. 7 orubel
    November 20, 2013 at 9:00 pm

    Even though Java is slow to develop in, GRAILS is NOT! Grails is extremely easy, Fast and has built in GORM that will auto generate your DB tables and relationships (once you have the domains built). No XML, no massive config files. Simple as pie.


Leave a comment


Design a site like this with WordPress.com
Get started