Play! is an excellent Web framework which is quite similar to Spring MVC on the view/controller aspect and is using Groovy as the view technology.
Spring usual views (JSP, JSTL, Freemarker, Velocity) are quite outdated and I do not understand why Spring does not improve them and why Matt Raible set their as a "pro" in his comparaison.
I believe in using the Grails View as the Spring MVC View. See my previous article about the "How To" and according to the Spring MVC roadmap, Grails View support will be added to Spring 3.1.
Let's benchmark Play! vs Spring MVC with Grails View. This microbenchmark will focus only on the view/controller performance.
- Core 2 Duo @ 3Ghz
- 6GB RAM
- Windows 7
- Play! 1.2 (standard configuration, production)
- Spring 3.1.0 M1 (production)
- Tomcat 7.0.12 (standard configuration, BIO) launch with CATALINA_OPTS equals to "-server -Xmx1024m"
ScenariiThe scenarii are the following :
- An empty controller rendering a simple view
- A parametrized controller with validation rendering a simple view. I reused a Play! controller from their Yabe tutorial
- A search controller rendering a complex view. I reused the Subbu benchmark sources
I run the Spring webapp on Tomcat 7 and I run the Play! webapp on Tomcat 7 and on the embeded server. I used the Apache HttpComponents toolkit to request the servers.
ProjectThe Spring project is available on github.
Search controller"results" is a Json object loaded at startup. This Json contains the results of an Ebay search request. See the Subbu's article for more info.
The viewI reused the view template of the Subbu project . The Grails View is quite similar.
- Play! is 25% ahead of Spring on the empty controller test.
- Spring is 20% ahead of Play! as soon as there is request's parameters.
- Spring is 70% ahead of Play! on the search test. The gap is quite important.
The most revelant test is the last one. Grails template engine is definitively more optimized than Play! template engine. As Play! and Grails used both Groovy, Play! template engine can clearly be improved.
Another interesting fact is that Play! with Tomcat (BIO) performs better than Play! embedded server ie. Netty (NIO). I don't know why, explanations are welcome!