Fresh Blurbs

Jetty Beats Tomcat's Performance (Quick Non-Scientific Test)

I was recently considering a servlet container to embed into a standalone application. My choice was pretty much between Tomcat and Jetty.

I like Jetty\'s compact approach. It only takes two jars: org.mortbay.jetty.jar (664KB) and javax.servlet.jar (138KB) to get going. In Tomcat\'s case you need much more jars total worth of 3.5MB in size. I, also, like the simple syntax for configuring and starting a servelt container from Jetty. Tomcat\'s system is too cumbersome, for my taste.

On the other hand one can argue that Tomcat is much more supported. Even JBoss switched to Tomcat, instead of Jetty (I suspect it was more of a political decision, though).

One more thing on Jetty\'s side is that its 6.x version will handle sockets NIO way. Even though 6.x is still beta, it\'s still much closer than Tomcat 5.5 developers of which still refuse to use NIO. They think they are smarter :)

I like, small, simple and robust solutions so, as you can guess, I was well in favor of Jetty only if... Only if it can scale and perform at least as well as Tomcat. Taste is important but making sure application is fast enough is the most important thing, for me (as it should be for every programmer).

Anyway, I decided to do a test and see what\'s worth what. I used latest stable versions of Tomcat ( 5.5.15) and Jetty (5.1.10). Honestly, my expectation was that Jetty would be slower (because Tomcat is so much more visible and supported project) but I wanted to know - how much slower? Significantly?

Let me say a few words about the test I performed. I used a tool developed by a colleague of mine Velmurugan Periasamy. This tool opens N sessions to a host using NIO sockets and measures cumulative download time, as well as the elapsed (user-experienced) download time. Since the tool is heavily multi-threaded cumulative time is, always, much longer than the elapsed time, of course. I deployed a very simple application to both Jetty and Tomcat: a WAR with Hello World index.jsp. My interest was to compare the two servers in regards with how efficiently they handle socket connections. I believe that\'s the measure of servlet container\'s "speed". Even if very simple (or primitive), it should give a good feel.

I ran tests against standalone, vanilla installations of Tomcat and Jetty. Two settings were used: 500 sessions and 5000 sessions. Number of NIO threads in the tool: 25.

How surprised I was to find out that Jetty, actually, performs MUCH better!\

500 sessions processed (each test setup ran 5 times and averaged): \ Tomcat: \ [ HttpClient ]:Cumulative Download Time:85033 \ [ HttpClient ]:Total Elapsed Time:2002 \ Jetty \ [ HttpClient ]:Cumulative Download Time:2717 \ [ HttpClient ]:Total Elapsed Time:1095

5,000 sessions processed (each test setup ran 5 times and averaged): \ Tomcat: \ [ HttpClient ]:Total Download Time:19621497 \ [ HttpClient ]:Total Elapsed Time:16933 \ Jetty: \ [ HttpClient ]:Total Download Time:38980 \ [ HttpClient ]:Total Elapsed Time:12232

Of course, it is not a lab-test and you should use your own judgement (or better - tests) before you "do it yourself home", but as far as I am concerned these tests are a good indication that Jetty\'s performance is, at least, as good as that of Tomcat\'s and I choose to believe - it is even superior.

P.S. I chose Jetty for the my project. Elegancy and performance in one - unbeatable combination.

comments powered by Disqus