Load Testing Java Applications
Author’s Note: This post was resurrected from an archived version of my website, and has been updated to point to current sources.
Part of my job as a Software Engineer at a local R&D company has been to work on load testing our J2EE application in order to find faults in our software, platforms, and to construct estimates about how much it will cost to host our application.
When I initially started testing our software, I turned to the Apache Jakarta project’s JMeter. The Apache guys continually put out top-notch software that’s incredibly useful. Apache’s self titled (and the world’s most popular) web server, Jakarta’s Tomcat, Ant, Log4J, Lucene, and Xerces are only a few of the project’s many pieces of software, and the list goes on and on. I’ve been using Apache software for years, and I’ve loved every minute. Their solutions are well documented (virtually unheard of in the universe of open source software), stable, and fast. Even some of their lesser known projects (such as those found in the Jakarta Commons) are gaining popularity among developers for filling in some of the gaps in Java and improving development velocity by minimizing duplicate effort (thanks in part to their truly free license, no stupid restrictions or requirements about source disclosure or commercial usage).
JMeter, however, is another story. In addition to poor and confusing documentation, the product is horrendously slow and difficult to work with. Using it on a single system is a challenge enough, and configuring it to play well with our testing cluster was an entirely new nightmare. The tool is designed to load test web (and other Internet protocol based) applications, but does a poor job of reporting statistics and almost forces you to use other tools or methods to find the slow portions of your applications.
After finally having enough of their software, I spent an hour or so Google’ing the net and found two potential candidates. Velometer, whose website has been unavailable since I found it in the search results and is still unreachable today, and The Grinder surfaced as viable alternatives to JMeter. Since I couldn’t obtain Velometer, I went ahead and tried The Grinder.
The Grinder, which was created for a book and has grown up over time, comes in two flavors. The stable version (2) uses a standard Java properties file to configure the tests, which isn’t optimal, but certainly palatable. However, the newest version (3) is right on the money. The Grinder 3 lets you specify your tests in Jython scripts. For those of you who aren’t familiar with Jython, it’s an embedded version of the object oriented scripting language Python, written in Java. Jython lets you write scripts in Python (which can be much faster than writing the code in Java, again increasing development velocity) and seamlessly integrate them with Java. (The power of embedding languages in Java—more specifically scripting languages—will be the subject of another blog).
Using The Grinder 3 you can load test anything that you can access from Java—EJBs, websites, Email systems, databases. You write the script and sick The Grinder on it, The Grinder takes care of the rest. The Grinder also lets you report results for different areas of your test separately (IE- testing INSERTs and SELECTs on a database, or login sequences and search queries on a webpage) in the results, making it easy to see how long specific operations take.
This is all old news for those of us who have used commercial testing tools in the past, but the real power of The Grinder is the ease of operation (I won’t even mention the unbeatable price point). I wrote a simple Jython script (I had never written a line of Python in my life) using the Python Documentation Online and the wonderful documentation available from The Grinder’s website. I then fired up the UI, started up the test clients on our cluster, and clicked start. Not only did it work with minimum configuration (and it automatically detected my three test categories without any configuration), but I went from a freshly downloaded tarball to fully functional test environment in about 2.5 hours. That’s powerful.
If you’re load testing apps, give The Grinder (3) a try. I’m sure you’ll find it very useful. It’s also worth mentioning that The Grinder’s team delivers what few open source projects can: a stable product and good documentation. In the coming days, weeks, and months, I’ll talk about other high quality open source projects that I have found.
Comments? Omissions? Questions? Leave a comment here in the blog or contact me directly.