Hi Esteemed folks, the intent of creating this blog is to share my day 2 day experiences/observations on implementation/design of java projects. I work as a senior java developer for an investment bank in NY and i enjoy coding a lot.
Recently i was given the task of evaluating struts 2 framework for our new project and i was very excited to adopt this in our team. i had used version 2.0.1 in my earlier job and it did help to achieve a cleaner design/less code at the presentation layer, but i was worried about the performance aspect of it, especially the custom tags and ognl expressions. but i read on the forum that they had worked on the performance issues in 2.0.11 and so i thought of taking a stab at this using the new release 2.0.11
I downloaded the Apache JMeter to benchmark the results. JMeter is a very lightweight performance evaluation tool from Apache and the learning curve was a couple of hours, believe me or not. Now lets get our hands a bit dirty. The first step was to write a simple jsp page with a few struts 2 form tags, input elements and a iterator tag which loops 100 times over a ognl expression, expression traverses an object to a dept level of 2.
JMeter has a feature of running the agent remotely which simulates the users hitting the web url. i installed the agent on 2 unix boxes. deployed the web application on weblogic 9.2 with JVM heap size of 1 GB on an intel dual core 2.4 GHz box. the test scenario consisted of 200 users hitting the same action url which then forward the request to the test jsp. no database calls were invoked. in my first run, the results were shocking, average response time being 5000 ms.
That kinda prompted me to look at tuning aspect of the framework, changed the dev flag to false, enabled template caching, set the JSP reload check to -1 etc, more details at
http://struts.apache.org/2.0.11/docs/performance-tuning.html and i ran the test scenario again and this time the results were dramatic, the average response time was less than 10 ms.
To conclude, you dont have to trade-off the performance of your web application by adopting struts 2. It definitely fits in with your performance requirements of a MVC framework, not to forget wealth of features it brings along. if you are curious about knowing more of struts 2, have a peek at my article
http://www.javaworld.com/javaworld/jw-10-2007/jw-10-struts2inaction.html which has a sample code that you can use to kick the tyres.
Feel free to drop a line in case i wasnt clear about anything and i would be glad to clarify/elaborate the same,
its 7.30 PM now, got to rush home,
cheers,
Venkat