Is performance of Grails 2.0 really that awfully low?

Xtra Coder picture Xtra Coder · Jan 12, 2012 · Viewed 8.6k times · Source

I'm somewhat newbie for WEB development based on JVM stack, but future project will require specifically some JVM-based WEB engine. So I started looking on some ground to make things quickly and turned to try Grails. Things looked good from the book, but beeing impressed by really long startup time (grails run-app) I decided to test how this works under load. Here it is:

  • test app: follow few instruction here to make it from ground (takes 2 mins assuming you already have Grails and Tomcat installed):

    _http://grails.org/Quick+Start

  • test case (with Apache benchmark - comes with Apache httpd - _http://httpd.apache.org):

    ab.exe -n 500 -c _http://localhost:8080/my-project/book/create
    (Note: this is just displays 2 input fields within styled container)

  • hardware: Intel i5 650 (4Core*3.2GHz) 8GB Ram & Win Server 2003 x64

The result is ..

Grails: 32 Req/Sec

Total transferred:      1380500 bytes
HTML transferred:       1297500 bytes
Requests per second:    32.45 [#/sec] (mean)
Time per request:       308.129 [ms] (mean)
Time per request:       30.813 [ms] (mean, across all concurrent requests)
Transfer rate:          87.51 [Kbytes/sec] received

(Only 32 Req/Sec with 100% of CPU saturation, this is a way too below my expectations for such hardware)

... Next - i tried to compare it for example with similar dummy JSF application (i took one here: _http://www.ibm.com/developerworks/library/j-jsf2/ - look for "Source code with JAR files", there is \jsf-example2\target\jsf-example2-1.0.war inside),

  • test case: ab.exe -n 500 -c 10 _http://localhost:8080/jsf/backend/listing.jsp

The result is ..

JSF: 400 Req/Sec

Total transferred:      5178234 bytes
HTML transferred:       5065734 bytes
Requests per second:    405.06 [#/sec] (mean)
Time per request:       24.688 [ms] (mean)
Time per request:       2.469 [ms] (mean, across all concurrent requests)
Transfer rate:          4096.65 [Kbytes/sec] received

... And finally goes raw dummy JSP (just for reference)

Jsp: 8000 req/sec:

<html>
<body>
<% for( int i = 0; i < 100; i ++ ) { %>
Dummy Jsp <%= i %> </br>
<% } %>
</body>
</html> 

Result:

Total transferred:      12365000 bytes
HTML transferred:       11120000 bytes
Requests per second:    7999.90 [#/sec] (mean)
Time per request:       1.250 [ms] (mean)
Time per request:       0.125 [ms] (mean, across all concurrent requests)
Transfer rate:          19320.07 [Kbytes/sec] received  

...

Am i missing something? ... and Grails app can run much better?

PS: I tried profiling my running Grails app with VisualVM, but got endless loop of messages like ...

Profiler Agent: Redefining 100 classes at idx 0, out of total 413
...
Profiler Agent: Redefining 100 classes at idx 0, out of total 769
...

And finally app just stopped working after few mins - so, looks like profiling Grails is no the choice for good diagnose.

Update - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

First of all I have to admin, yes i need to RTFM - i.e. 'grails run-app' is not the correct way to run Grails for performance measurement. After compiling WAR and deploying it to Tomcat performance is not that awfully low - it is just low. The metrics below are for concurrency of 1 user (I just wanted to check what is MAX performance of the framework in one thread and with no heavy load) and while reading other related posts here i came to "http://stackoverflow.com/questions/819684/jsf-and-spring-performance-vs-poor-jsp-performance" and decided to check Apache Wicket mentioned there - its performance is also included.

Use case is: - ab.exe -n 500 -c 1 _http://localhost:8080/... - server is Tomcat7 in vFabric tcServer Dev edition with 'insight' running on background

----------------------   tcServer       Plain Tomcat 7    -c 10
/Grails/book/create      77 req/sec     130 req/sec       410 req/sec
/jsf/backend/listing.jsp 133 req/sec    194 req/sec       395 req/sec
/wicket/library/         870 req/sec    1400 req/sec      5300 req/sec

So ... anyway there is something wrong with Grails. I have made some profiling using tcServer (thanks Karthick) - it looks like it is able only to trace 'Spring-based' actions and internal stacktrace for Grails is like following (for 2 requests - note: metrics are not stable - i bet accuracy of tcServer far from beeing perfect, but can be used just for inforamtion)

Total (81ms)
    Filter: urlMapping (32ms)
        -> SimpleGrailsController#handleRequest (26ms)
        -> Render view "/book/create" (4ms)
    Render view "/layouts/main.gsp" (47ms)

Total (79ms)
    Filter: urlMapping (56ms) ->
        -> SimpleGrailsController#handleRequest (4ms)
        -> Render view "/book/create" (38ms)
    Render view "/layouts/main.gsp" (22ms)

PS: it may happen that the root cause for bad performance in Grails are underlying 'Spring' libs, will check this in more details.

Answer

Stephen Eilert picture Stephen Eilert · Jan 12, 2012

Are you running it with run-app?

http://grails.org/Deployment states:

"Grails should never be deployed using the grails run-app command as this sets Grails up in "development" mode which has additional overheads. "