This wiki will show you how to set up JMeter and start running Load Test. Apache JMeter may be used to test performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types. You can use it to make a graphical analysis of performance or to test your server/script/object behavior under heavy concurrent load. Apache JMeter features include:
Get the latest JMeter version here: JMeter Download - Installing and Running JMeterThe most recent release of JMeter is version 2.6. You can download the latest stable version from. Downloads area available as either Once you extract the binary distribution file, JMeter is ready for you. On Linux/UNIX, run JMeter by invoking the The user interface has two panes. The left pane displays the elements used in our testing. Initially, there are the Root and two sub-elements, Test Plan and WorkBench. In this article we're only concerned with Test Plans. Add an element to a node by right-clicking it and selecting Add. To remove an element, select the element by clicking on it, then right-click on the element and choose the Remove option. The right pane of the user interface displays the details of each element. You are now ready to use JMeter. There are two things to note:
Using JMeter for a Simple TestLet's start with a very simple test. In this test, we will set up a test plan and stress test a Web application. You will be introduced with some common concepts in JMeter. After understanding this basic test, you should be able to use all of the capabilities of JMeter. To conduct a test, you must have a test plan. A test plan describes the steps that JMeter will take to perform the testing. A test plan includes elements such as thread groups, logic controllers, sample generating controllers, listeners, timers, assertions, and configuration elements. Don't worry at this stage if you don't understand what these elements are. A test plan must have at least one thread group. A thread group is the starting point of a test plan, and it can contain all other JMeter elements. A thread group controls the threads that will be created by JMeter to simulate simultaneous users. Now, let's start by creating a thread group. Right-click the Test Plan element and select Add and then Thread Group. JMeter will create a thread group element under Test Plan element. Click the Thread Group element, and you will see a screen like the one in Figure 2. In this page, you can set the following properties:
For our simple test, fill the properties with the values found in Figure 2. We will use two users and each test will be performed three times. We use small numbers here so that we can easily explain the results later; in real load testing, you might want to use higher numbers for these properties. Next, you need to add the element that represents HTTP requests. To do so, right-click the Thread Group element, and select Add, Sampler, and then HTTP Request. An HTTP Request element will be added to the Thread Group element. Click the HTTP Request element to select it, and you should see a screen similar to Figure 3. On the HTTP Request screen, you configure the HTTP requests that will be used to "hit" your application. Here, you can set the following properties.
Now you should be able to figure out the values for the properties in the HTTP Request page. The last element that we need to add to our test plan is a listener, which in JMeter is the same as a report. JMeter comes with various reports to choose from. A report can be a table or a graph. For this testing, use the easiest report available: a table. To add a listener, right-click the Thread Group element, select Add, and then Listener and View Results in Table. Now you are ready to run the test plan. Before you run your test plan, however, you are advised to save the test plan just in case JMeter crashes the system (an occasional occurrence with higher numbers of threads and loop counts). Afterwards, select Start from the Run menu to execute the test plan. While the test plan executes, the small box on the bar right below the menu bar will turn green. For a test that does not run indefinitely, JMeter will automatically stop the test plan after it's finished. For a test that goes on indefinitely, you must intervene to stop the test. Do this by selecting Stop from the Run menu. When I ran my test plan, I got the results like those shown in Figure 4. It is very easy to understand the figures in the table. There are six samples taken (two threads and three loop counts, thus 2 x 3 = 6). The response time from each sample is given in the third column. They are 100, 60, 260, 50, 120, and 80 ms. All samples are taken successfully, as described by the fourth column. On average, each sample has a response time of 111 ms ((100 + 60 + 260 + 50 + 120 + 80)/6). Another important figure is the standard deviation, defined as the square root of the total of the deviation of each sample from the average. This figure indicates how stable your Web application is. If the standard deviation is high, some users will experience very good responses while some other users will wait for a longer time. The smaller this value, the better. After conducting a simple test, it is very easy to do more complex tests. For load testing Web applications, increase the number of threads and the loop counts gradually and see how your applications cope with the loads. The following sections of this article tackle some other important aspects of load-testing Web applications with JMeter. ListenersJMeter comes with a number of listeners or reports. In the previous test, we used a table to display the test results. If this is not suitable for you, you can choose one or more of the other listeners for a thread group. A popular listener is the Graph Results, as shown in Figure 5. Multiple HTTP RequestsA real application has multiple resources, both static and dynamic. Chances are, you want to see the performance of these resources. JMeter makes it easy to employ multiple HTTP requests. Just add any number of HTTP Request elements and configure them, as in the previous test. If you have multiple HTTP Request elements, you might want to use a HTTP Request Defaults element, described in the following section. HTTP Request DefaultsThe HTTP Request Defaults element specifies the default values of existing HTTP Request elements within the same thread group. The HTTP Request Defaults element is especially useful because most, if not all, HTTP Request elements normally have the same server and port. Figure 6 shows the detail page of a HTTP Request Defaults element. Add an HTTP Request Default element by right-clicking a Thread Group element and then selecting Add, Config Element, and HTTP Request Default. Cookie ManagerMany Web applications use cookies. JMeter provides cookie capabilities through a Cookie Manager. Adding this element to a thread group allows you to send cookies to the application being tested, just as Web browsers do. Figure 7 displays the details page of a Cookie Manager. Here you can add and delete a cookie. You can add a Cookie Manager element by right-clicking a Thread Group element and then selecting Add, Config Element, and Cookie Manager. JMeter URLS
|