twitter
612-605-1977
f 612-605-1978

Tomcat Performance Tools

Posted by dave on Feb 22, 2013 in Blog | Subscribe

Tomcat is very popular for the deployment of J2EE web applications that we write at Kettle River. As a matter of fact, the majority of our clients use Tomcat for their Java application server. Most of these applications persist their data in a relational database. Additionally these applications may use external Web services to add features or get data from external systems.

Prudent application development techniques perform well for the anticipated workload. These techniques include
• Sound relational database design
• Proper database implementation
• Database tuning including indexes and transaction management
• Proper attention to the performance of external Web services
• Adequate hardware for the application including memory and disk subsystem.
It is interesting that most of these application development techniques focus on the database. This is because in our experience this is where the most problems lie. Modern hardware (physical or virtualized) can minimize the performance impacts of bad code on processor performance. But you can’t get away from the cost of accessing a disk drive or a network to access the database. A bad database call that takes a second on average that is called every time a page is displayed is going to make for a slow application.

Why is performance important? One obvious reason that applies to internal sites is user productivity. For e-commerce sites, a slow web site can hinder conversion rates. Statistics show that a users will “bounce” or leave a slow web site with alarming frequency. Data from O’Reilly indicates that 2 second slowdown drops revenue by 4%. has a nice writeup on how speeding up a web site improves business for more niche e-commerce sites.

So performance is important. What do you do when performance is poor? Or what do you do to prove to your management that your Web application meets its scalability and performance requirements? Most developers start looking for “obvious” bottlenecks and start optimizing away. Sometimes that approach works, but most of the time this approach leads to un-necessary changes. Or the team makes changes that actually hurt performance.

At Kettle River we use two tools to determine what is causing Tomcat applications to slow down. Those tools are VisualVM and psi-probe. VisualVM provides information about memory usage, garbage collection, CPU and other vital information about an application under test. It is very handy in the situations where you have a test environment that can replicate a performance issue. “psi-probe” is useful in a production environment when you can’t replicate the issue in a test environment.

VirtualVM shows a running Tomcat instance using JMX. There are a bunch of good tutorials on how to run VirtualVM. Here are a couple of possibilities.

Connecting Visual VM to Tomcat
Running VisualVM over SSH

VirtualVM produces some pretty graphs which can give you a quick visual idea as to what is happening. Here is a sample.

VisualVM 1.3.5

 

 

 

 

 

 

“psi-probe” is a web application that deploys in the container so it does not affect your running code. “psi-probe” is available at .
If you suspect a memory issue, psi-probe can show the memory usage. The screenshot below shows a running system with 2 GB of heap allocated to the system. Note that you can advise garbage collection to the application as well as observe the memory usage. This can be quite handy.

 

psi-probe screenshot

 

 

 

 

 

Both psi-probe and VirtualVM are JMX based. So if your application is completely wrapped around the axle, you may not be able to see much. But these tools are invaluable for tracking down performance issues.

While tools like VirtualVM and psi-probe can point out issues, the key is interpretation of the results. It is easy to draw conclusions that may not be correct about the cause of a performance issue. Careful gathering of metrics and analysis are vital to a successful performance tuning program. At the risk of sounding self-service, hiring a consultant that has experience can help isolate performance issues faster and train your team on how to use these tools to their best effect.

Reply