You are on page 1of 34

JMeter

A Performance Testing Tool


Date:08/09/2009

Testing:Performance/Load/Stress
Performance Testing usage) Demonstrates that the system meets performance criteria. How fast an application perform under particular work load. Validation,verification of quality attributes (scalability, reliability, resource

Load Testing Modeling the expected usage by simulating multiple users accessing the web

services concurrently Raised beyond normal usage

Stress Testing Determination of stability of an application Tries to break the application by overwhelming its resources

May 13, 2009

Before Starting
What is our estimated number of users (normal load)? What is our anticipated peak number of users? When is a good time to load-test our application(i.e. Off-hours or weekends) keeping

in mind that this may very well crash one or more of our servers?
What is the testing intended to achieve? Sequential Functional (low volume)

Benchmark ( the average number of users)


Load-test (the maximum number of users) Test destructively (what is our hard limit)

May 13, 2009

Introduction
Definition JMeter is an Apache Jakarta project that can be used as a load testing tool for analysing and measuring the performance of a variety of services, with a focus on web applications Why JMeter JMeter can be used as a unit test tool for JDBC database connection, FTP, LDAP, WebServices, JMS, HTTP and generic TCP connections. JMeter can also be configured

as a monitor, although this is typically considered an ad-hoc solution in lieu of advanced


monitoring solutions.

May 13, 2009

Introduction - Features
100% pure Java Open Source Desktop application Designed for performance/functional/load/stress testing Extensible- write your own tests

Pluggable sampler allows unlimited testing capabilities


Simulate heavy load (application, server and network) Gives instant visual feedback Distributed testing

Various protocols- HTTP, JDBC, LDAP, SOAP, JMS, FTP


Multi-platform Full multi-threading framework Test plans can be stored in XML and can be version controlled Caching and offline analysis/ replaying of test results

May 13, 2009

JMeter Installation - Requirements


Java Version - Requires fully complaint JVM 1.4 or higher - Version 2.2 and later no longer support Java 1.3 Operating system

- JMeter is a 100% Java application and should runs correctly on any machine
with complaint Java implementation - Tested and works under Unix (Solaris, Linux, etc) Windows (98, NT, XP, etc) Open VMS alpha 7.3+

May 13, 2009

JMeter Installation Setting up and Running


Make sure the system contains Java 1.4 or later

Make sure JAVA_HOME environment variable set correctly


Download the latest binary from Jakarta - http://jakarta.apache.org/jmeter/

Unpack the zip or tar.gz in any directory Go to the Jakarta-JMeter directory (directory in which the zip or tar.gz file is unpacked)

Type ./bin/jmeter on command prompt (for Unix) or Run jmeter.bat (for windows) JMeter is ready to test application

May 13, 2009

JMeter Installation Directory Structure


The installation directory structure should look something like this (for version 2.3.1): jakarta-jmeter-2.3.1 jakarta-jmeter-2.3.1/bin jakarta-jmeter-2.3.1/docs jakarta-jmeter-2.3.1/extras jakarta-jmeter-2.3.1/lib/ jakarta-jmeter-2.3.1/lib/ext jakarta-jmeter-2.3.1/lib/junit jakarta-jmeter-2.3.1/printable_docs We could rename the parent directory (i.e. jakarta-jmeter-2.3.1) but do not change any of the sub-directory names.

May 13, 2009

JMeter - After Installation

May 13, 2009

JMeter Running Using a Proxy Server


JMeter should be provided with the firewall/proxy server hostname and port number if testing is done behind a firewall/proxy server Run the jmeter.bat/jmeter file from a command line with the following parameters: -H [proxy server hostname or ip address] -P [proxy server port] -N [nonproxy hosts] (e.g. *.apache.org|localhost) -u [username for proxy authentication - if required] -a [password for proxy authentication - if required] Example : jmeter -H my.proxy.server -P 8000 -u username -a password -N localhost Alternatively, you can use --proxyHost, --proxyPort, --username, and --password

10

May 13, 2009

JMeter Running Non-GUI Mode (Command Line Mode)


For non-interactive testing, run JMeter without the GUI by using following command options -n This specifies JMeter is to run in non-gui mode -t [name of JMX file that contains the Test Plan]. -l [name of JTL file to log sample results to]. -r Run the test in the servers specified by the JMeter property "remote_hosts"

-R [list of remote servers] Run the test in the specified remote servers
The script also lets you specify the optional firewall/proxy server information: -H [proxy server hostname or ip address] -P [proxy server port] Example : jmeter -n -t my_test.jmx -l log.jtl -H my.proxy.server -P 8000

11

May 13, 2009

Elements of Testplan
Thread Group - The beginning points of any test plan Allows to Set the number of threads

Logic Controllers

Set the ramp-up period


Set the number of times to execute the test

Let you customize the logic that JMeter uses to decide when to send requests

Samplers - Tell JMeter to send requests to a server and wait for a response

12

May 13, 2009

Elements of Testplan contd...


Configuration elements Work closely with samplers Can add or modify requests

Pre-processor elements
Executes some action prior to a Sampler Request being made most often used to modify the settings of a Sample Request just before it runs

or to update variables that aren't extracted from response text

Post-processor elements executes some action after a Sampler Request has been made most often used to process the response data, often to extract values from it

13

May 13, 2009

Elements of Testplan contd...


Timers Specifies the delay between sending consecutive requests

Listeners

Used for result analysis

Assertions Allow you to assert facts about responses received from the server being tested

14

May 13, 2009

Elements of Testplan
Thread Group
Logic Controller

Configuration Element

Sampler s

Preprocessor Elements Post-processor Elements Timers Assertions Listeners

15

May 13, 2009

Execution Order
Timers Preprocessors Samplers

Post-processors
Assertions Listeners

16

May 13, 2009

Building a Test Plan : Adding an element


To add an element, Right click on an element in the tree Choose the new element from the add list

17

May 13, 2009

Building a Test Plan : Loading and saving element


To load the element, right click on the existing tree element select the "open" option

18

May 13, 2009

Building a Test Plan : Saving the Test Plan


To save the test plan, select Save Test Plan from the File menu

19

May 13, 2009

Building a Test Plan : Running the Test Plan


To run the test plan, Go to Run menu Choose Start

OR

Press Ctrl+R

20

May 13, 2009

Building a Test Plan : Stopping the Test


There are two types of Stop command, Stop (Control + '.') stops the threads immediately if possible Shutdown (Control + ',') requests the threads to stop at the end of any current work

21

May 13, 2009

Building a Test plan : Error Reporting


JMeter reports warnings and errors to the jmeter.log file and some information on the test run itself. Some errors which are unable to trap and log by JMeter would be appeared on the command console. Sampling errors (e.g. HTTP 404 - file not found) are not normally reported in the log file. Instead these are stored as attributes of the sample result. The status of a sample result can be seen in the various different Listeners

22

May 13, 2009

Life-cycle

Plan Test

Create Thread Group

Create Test Script

Run Test Plan

Analyze Results

Test Plan

Thread Group Schedulers

Sampler s Timers

Listeners

23

May 13, 2009

Analyzing Results
JMeter supports this step by: displaying the data visually (Graph Results) save data in file

allows user to see one multiple views of the data


displays the response from the server. shows the URL of each sample taken . listeners will show different sets of data.

24

May 13, 2009

Advantages
It is free Easy to install and use Compared to other load and performance testing tools, it is not only for web

application, but also for other servers or objects


Test results can be shown in different formats Highly extensible

25

May 13, 2009

Demo

26

May 13, 2009

Building a Web test plan


Adding Users Adding Default HTTP Request Properties Add HTTP Request

Add listener to view store the Test Result

27

May 13, 2009

Building a Web test plan Adding Users

28

May 13, 2009

Building a Web test plan Adding Default HTTP


Request Properties

29

May 13, 2009

Building a Web test plan Adding HTTP Request

30

May 13, 2009

Building a Web test plan - Add listener to view store the


Test Result

31

May 13, 2009

Building a Web test plan Result Summary

32

May 13, 2009

Tips
Use timers to avoid hammering the server Limit the Number of Threads

- Hardware will limit the number of threads you can effectively run. A faster machine makes JMeter work harder since it returns request quicker. User variables

- Create a text file containing the user names and passwords. - Add a CSV DataSet configuration element. Name the variables USER and PASS. Use ${USER} and ${PASS} within samplers. Reducing resource requirements

- Use non-GUI mode. - Use as few Listeners as possible. - Reduce samplers by looping (by thread and by controller), and use variables (CSV Data Set) to vary the sample. - Use CSV output rather than XML.

33

May 13, 2009

Thank You !

You might also like