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:
- PHP 5.3.3 on Apache 2.2.21
- Ruby 1.8.7 + Rails 3.1.3 on mongrel 1.1.5
- JRuby 1.6.5 (emulating Ruby 1.8.7) + Rails 3.1.3 on mongrel 1.1.5
- Grails 2.0.0 (Groovy 1.8.4) on Tomcat 7.0.16
- 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.
Hi Rusty,
Thanks for sharing those numbers with the community… Do you have the testing code checked-in somewhere?
Thanks
Marcello
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 –
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.
it’s really tough to beat the performance and speed of Java. Groovy, Clojure and Scala would be better for Java benchmarking comparisons. IMHO
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.
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.
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.