JMeter can be run in either graphical mode or in text-only mode. You may run JMeter test plans in either mode, but you must create the test plans in graphical mode. The test plans are stored as XML configuration documents. If you need to change only a single numeric or string value in the configuration of a test plan, you can probably change it with a text editor, but itís a good idea to edit them inside the graphical JMeter application for validityís sake.
Before trying to run JMeter to run a benchmark test against Tomcat, make sure that you start JMeterís JVM with enough heap memory so that it doesnít slow down while it does its own garbage collection in the middle of trying to benchmark. This is especially important if you are doing benchmark testing in graphical mode. In the bin/jmeter startup script, there is a configuration setting for the heap memory size that looks like this:
# This is the base heap size -- you may increase or decrease it to fit your
It will make use of as much heap memory as you can give it; the more it has, the less often it may need to perform garbage collection. If you have enough memory in the machine on which youíre running JMeter, you should change both of the256numbers to something higher, such as512. It is important to do this first because this settingís default could skew your benchmark test results.
To create a test plan for the benchmark, first run JMeter in graphical mode, like this:
JMeterís screen is laid out as a tree view on the left and a selection details panel on the right. Select something in the tree view and you can see the details of that item in the details panel on the right. To run any tests, you must assemble and configure the proper objects in the tree, and then JMeter can run the test and report the results.
To set up a benchmark test like the one we did above with both ab and siege, do this:
Figure 4-1 shows the JMeter GUI with the test plan, assembled and ready to run. The tree view is on the left, and the detail panel is on the right.
Once you are done building and saving your test plan, you are ready to run the benchmark. ChooseFile -> Exitfrom the top pull-down menu to exit from the graphical JMeter application. Then, run JMeter in text-only mode on the command line to perform the benchmark, like this:
$ bin/jmeter -n -t tc-home-page-benchmark.jmx
Notice that the requests per second reported by JMeter (an average of1408.8requests per second) is significantly lower than that reported by both ab and siege, for the same hardware, the same version of Tomcat, and the same benchmark. This demonstrates that JMeterís HTTP client is slower than that of ab and siege. You can use JMeter to find out if a change to your webapp, your Tomcat installation, or your JVM, accelerates or slows the response times of web pages; however, you cannot use
JMeter to determine the serverís maximum number of requests per second that it can successfully serve because JMeterís HTTP client appears to be slower than Tomcatís server code.
You may also graph the test results in JMeter. To do this, run JMeter in graphical mode again, then:
Now, youíre ready to rerun your test and watch as JMeter graphs the results in real time.
When youíre ready to run the test, you can either selectRun -> Start from the top pull-down menu, or you can hit Ctrl-R. The benchmark test will start again, but you will see the results graph being drawn as the responses are collected by JMeter. Figure 4-2 shows the JMeter GUI graphing the test results.
You can either let the test run to completion or you can stop the test by hitting Ctrl-. (hold down the Control key and hit the period key). If you stop the test early, it will likely take JMeter some seconds to stop and reap all of the threads in the requestThread Group. To erase the graph before restarting the test, hit Ctrl-E. You can also erase the graph in the middle of a running test, and the test will continue on, plotting the graph from that sample onward.
Using JMeter to graph the results gives you a window into the running test so you can watch it and fix any problems with the test and tailor it to your needs before running it on the command line. Once you think you have the test set up just right, save a test plan that does notGraph Results, but has a
JMeter also has many more features that may help you test your webapps in numerous ways. See the online documentation for more information about this great test tool at http://jakarta.apache.org/jmeter.
blog comments powered by Disqus