Main Content

Using ApacheBench and jconsole to test and monitor Tomcat

Archive - Originally posted on "The Horse's Mouth" - 2009-03-14 12:22:35 - Graham Ellis

jconsole lets you monitor Tomcat or another Java application so that you can see how much memory is in use, how many threads you have running, how many classes, etc.

Here's an example of a Tomcat server that was sitting virtually unused ... which we then exercised through ApacheBench - the ab utility that's supplied with Apache httpd, as follows:

ab -n 2000 -c 30 http://192.168.200.215:8080/whm_course/demo.jsp

That's calling for a page to be loaded 2,000 times - with a concurrency of 30 (in other words for there to be 30 connections all at the same time, simulating visits from 30 different places.

Not surprisingly, the effect of sending 30 concurrent requests was that Tomcat started another 30 threads to handle them (!) and those threads between them grabbed anothe4 4 Mbyes or so of memory. The cpu usage spiked to around 20%. What is interesting to note is that - once created - the threads live on in case further requests come in.