2. INDEX
Introduction.
How do we do it ?
How we make parameters dynamic, reacting to the
unique server responses of each test run?
How do we use external data files to define variables
in my Test scripts?
Does JMeter process dynamic pages
JMeter keeps getting "Out of Memory" errors.
JMeter Distributed Testing Step-by-step
JMeter proxy Step-by-step
Configure your browser to use the JMeter HTTP
Proxy
Conclusion
References
3. INTRODUCTION
JMeter is an Apache Jakarta project that can be used as a load testing tool
for analyzing and measuring the performance of a variety of services, with a
focus on web applications.
Apache JMeter is a 100% pure Java desktop application designed to load
test client/server software (such as a web application ). It may be used to
test performance both on static and dynamic resources such as static files,
Java Servlets, CGI scripts, Java objects, databases , FTP servers , and
more. JMeter 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.
Stefano Mazzocchi of the Apache Software Foundation was the original
developer of JMeter. He wrote it primarily to test the performance of Apache
JServ (a project that has since been replaced by the Apache Tomcat
project). We redesigned JMeter to enhance the GUI and to add functional-
testing capabilities.
4. Why to use JMeter ?
JMeter can be used as a unit test tool for JDBC database connection,
FTP, LDAP, WebServices,J MS, 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.
JMeter is not a browser.
JMeter is not a browser. As far as web-services and remote services are
concerned, JMeter looks like a browser (or rather, multiple browsers);
however JMeter does not perform all the actions supported by browsers. In
particular, JMeter does not execute the Javascript found in HTML pages.
Nor does it render the HTML pages as a browser does .
Features
Full multithreading framework allows concurrent sampling by many threads
and simultaneous sampling of different functions by separate thread groups.
Careful GUI design allows faster operation and more precise timings.
Caching and offline analysis/replaying of test results.
7. How we make parameters dynamic, reacting
to the unique server responses of each test
run?we can use the Regular Expression Post Processor to extract a value from a
response, and then reuse this response in another request. Looking at the previous
question in this FAQ, you could extract the product id from the result and use it in
the following request:
1. Load Test Plan created in previous FAQ question.
2. Add Post Processor > Regular Expression Extractor to thread Group with following values:
1. Reference Name: product
2. Regular Expression: product_id=(w*-w*-w*)
3. Template: $1$
4. Match No.: 0 (Setting this parameter to 0 returns a random match)
3. Copy the HTTP Request we created in the previous question and paste to the thread group
after the previous HTTP Request.
4. Change the following values:
1. Path: /estore/control/product
2. Add Parameter and set name to product_id, value to ${product}
5. Save Test Plan
6. Run > Start
When you view the results in the View Results Tree, you can see the ${product}
value was replaced with the value extracted by the regular expression.
8. How do we use external data files to define
variables in my Test scripts?
1. The CSV Data Set Config element is the best way to do this, as it can create
multiple variables from a single data file. Or Start JMeter,
2. Add a Thread Group to the Test Plan
1. set the appropriate number of threads and iterations.
3. Add Pre Processors > User Parameters to Thread Group.
4. Click Add Variable
1. Set Update once per iteration
2. Set the Name to the name of the variable (e.g. ACCOUNTID)
3. Set the value (under User_1) to ${_StringFromFile(accounts.dat)}
5. Add Sampler > HTTP Request to Thread Group:
6. Click the Add button to add a parameter to the request:
1. Name: account_id
2. Value: ${ACCOUNTID}
7. Add Listener > View Results Tree to Thread Group.
8. Save.
9. create the file accounts.dat containing one line per account id. If it is not in the bin
directory, then modify the StringFromFile parameter accordingly,
10. Run > Start
9. Does JMeter process dynamic pages
No,
JMeter does not process Javascript or applets embedded in
HTML pages.
JMeter can download the relevant resources (some embedded
resources are downloaded automatically if the correct options are
set), but it does not process the HTML and execute any
Javascript functions.
If the page uses Javascript to build up a URL or submit a form,
you can use the Proxy Recording facility to create the necessary
sampler. If this is not possible, then manual inspection of the code
may be needed to determine what the Javascript is doing.
If there are several nodes running the JMeter test plan, it is a
good idea to try and ensure that their clocks are synchronised, as
this makes it easier to analyze the data later.
10. JMeter keeps getting "Out of Memory" errors.
This is usually caused by including memory intensive listeners in
your stress test. Listeners like "View Tree Results" are useful for
debugging your test, but they are too memory intensive to remain
in your test when you ramp up the number of simulated users and
iterations. The best listeners to use for a long-term, high-load test
are Aggregate Listener, Graph Listener, and Spline Listener.
In addition, you can instruct the JVM to use more memory by
editing the jmeter/jmeter.bat files for linux/windows. Within these
files, find a section that sets values for the Heap:
set HEAP=-Xms256m -Xmx256m
Feel free to change these values. Xms indicates the starting RAM
the jvm will take, and Xmx will be the maximum it is allowed (for
the HEAP).
11. JMeter Distributed Testing Step-by-step
This explains how to use multiple systems to perform stress
testing. Before we start, there are a couple of things to check.
1. the firewalls on the systems are turned off.
2. all the clients are on the same subnet.
3. the server is in the same subnet, if 192.x.x.x or 10.x.x.x ip
addresses are used. If the server doesn't use 192 or 10 ip
address, there shouldn't be any problems.
4. Make sure JMeter can access the server.
5. Make sure you use the same version of JMeter on all the
systems. Mixing versions may not work correctly.
Once you've made sure the systems are ready, it's time to
setup remote testing. The tutorial assumes you already have
JMeter installed on all the systems. The way JMeter works is 1
master controller initiates the test on multiple slave systems.
12. 1. Terminology
Before we dive into the step-by-step instructions, it's a good idea to define the
terms and make sure the definition is clear.
Master – the system running JMeter GUI, which controls the test.
Slave – the system running JMeter-server, which takes commands from the GUI and
send requests to the target system(s).
Target – the web server we plan to stress test.
14. Step by step
1. On the slave systems, go to jmeter/bin directory and execute jmeter-server.bat
(jmeter-server on unix). On windows, you should see a dos window appear with
“jre[version]binrmiregistry.exe”. If this doesn't happen, it means either the
environment settings are not right, or there are multiple JRE installed on the system.
Note: [version] would be the jre version installed on the system.
1. Open jmeter-server.bat in a text editor
2. go to line 44 and find “:setCP”
3. edit “START rmiregistry” to the full path. Example: “START
C:<JAVA_HOME>jrebinrmiregistry”
2. On master system acting as the console, open windows explorer and go to
jmeter/bin directory
3. open jmeter.properties in a text editor
4. edit the line “remote_hosts=127.0.0.1”
5. add the IP address. For example, if I have jmeter server running on 192.168.0.10,
11, 12, 13, and 14, the entry would like like this:
remote_hosts=192.168.0.10,192.168.0.11,192.168.0.12,192.168.0.13,192.168.0.14
6. Start jmeter.
7. Open the test plan you want to use
15. Starting the Test
At this point, you are ready to start load testing. If you want to double
check the slave systems are working, open jmeter.log in notepad. You
should see the following in the log.
Jmeter.engine.RemoteJMeterEngineImpl: Starting backing engine
If you do not see this message, it means JMeter-server did not start
correctly. For tips on debugging the issue, go to the tips section. There
are two ways to initiate the test: a single system and all systems.
16. 1. click Run at the top
2. select Remote start
3. select the IP address
17. 1. click Run at the top.
2. select Remote start all or use CRTL-Z.
18. Limitations:
There are some basic limitations for distributed testing. Here's the list of the known items in no specific order.
1. RMI cannot communicate across subnets without a proxy; therefore neither can jmeter without a proxy.
2. Since JMeter sends all the test results to the controlling console, it is easy to saturate the network IO. It is a good idea to
use the simple data writer to save the results and view the file later with one of the graph listeners.
3. Unless the server is a large multi processor system, in most cases 1-2 clients is sufficient to overwhelm the server.
4. A single JMeter client running on a 2-3Ghz CPU (recent cpu) can handle 300-600 threads depending on the type of test.
(The exception is the webservices). XML processing is CPU intensive and will rapidly consume all the CPU cycles. As a
general rule, the performance of XML centric applications will perform 4-10 slower than applications using binary protocols.
Tips
In some cases, the firewall may still be blocking RMI traffic.
Symantec Anti Virus and Firewall,
In some cases, Symantec firewall needs to be stopped from windows services.
1. open control panel
2. open administrative tools
3. double click services
4. Go to down to symantec anti virus, right click and select stop
Windows firewall
1. open network connections
2. select the network connection
3. right click and select properties
4. select advanced tab
5. uncheck internet connection firewall
Linux
On Suse linux, ipchains is turned on by default. For instructions, please refer to the “remote testing” in the user manual.
On RedHat (or derivatives), iptables (netfilter) is turned on by default. Execute “service iptables stop” to stop the
Linux netfilter firewall.
19. JMeter proxy Step-by-step
8.1 Basic Proxy Instructions
1. Go to JMETER_HOME/bin and start JMeter with jmeterw.cmd on Windows and jmeter on
Linux/Unix
2. Select “Test Plan” on the tree
3. Right click on the “Test Plan” and add a new thread group: Add > Threads (Users) >
Thread Group
20. 4. Select the Thread Group
5. Right click “Add -> Config Element -> Http Request Defaults”
6. In new HTTP Request Defaults element: Server name – enter “jmeter.apache.org”
7. Path leave Blank.
21. 6. In new HTTP Request Defaults element: Server name – enter “jmeter.apache.org”
7. Path leave Blank.
8. Right click on the “Thread Group” and add a recording controller: Add > Logic Controller >
Recording Controller
22. 9. Next, select WorkBench
10. Right click on WorkBench and add the Http proxy: Add -> Non-test elements -> HttpProxy Server
23. 11. On HTTP Proxy Server, click the “Add” button in “URL Patterns to Include”. This will
create a blank entry.
12. Enter “.*.html”
13. Click 3 times, the “Add” button in “URL Patterns to Exclude”. This will create 3 blank
entries.
14. Enter “.*.png” pattern, “.*.gif” pattern and “.*.ico” pattern
24. 15. Right click on “HTTP Proxy Server” and add a listener: Add ->
Listener -> View Results Tree.
25. Return to HTTP Proxy Server, and click the “Start” button at the bottom.
26. Configure your browser to use the JMeter HTTP
ProxyAt this point, JMeter's proxy is running. For this exercise, we will use
Iceweasel/Firefox to view some pages on JMeter.
13. Start Iceweasel/Firefox, but do not close Jmeter.
14. From the tool bar, click “Edit -> Preferences” (or “Tools > Preferences”).
This should bring up the options.
15. Select the “Advanced” tab, and “Network” tab
16. Click “Settings” button near the
bottom.
27. 17. On the new popup, check “Manual proxy configuration”. The
address and port fields should be enabled now.
18. Address – enter “localhost” or the IP address of your system
19. Port – enter “8080”.
20. Check “Use this proxy server for all protocols”.
28. 21. Click “ok” button
22. Click “ok” button again. This should return you to the browser
9.1 Record your navigation
23. With your brower, in the “Address” bar at the top, enter
“http://jmeter.apache.org/index.html” and hit the “enter” key.
24. Click on a few links on JMeter's pages.
25. Close your browser and bring up the JMeter window.
Expand the thread group and there should be several samplers. At this point, the test plan can
be saved as is. If you forget to add default http request settings, you will have to
manually delete the servername, and port.
29. In this sample, there aren't any default request parameters. If a particular request
parameter is required by all pages, the request defaults is where one would add the
entries.
25. Select “Thread Group”
26. Right click “Add -> Listener -> Summary Report” to add an summary listener.
31. 27. Select “Thread Group”
28. Number of Threads – enter “5”
29. Ramp up Period – do not change
30. Loop Count – enter 100
32. 9.2 Start the test
At this point, we are ready to run our test plan and see what happens. Save
the test plan. When you're ready to run the test, there's two ways:
1. Run -> Start
2. Ctrl–R
Before you start the test, select “Summary Report”. As the test runs, the statistics will change until the test is done.
At the end of the test, the summary report should look like this
33. While the test is running, in the upper right-hand corner, there should be a
green square. When the test is done, the box should be grey.
Benefits:
1. Its pure Java tool, which allows to execute this tool in any platform (i.e. platform
independent)
2. Its have lot many configuration mechanism like Htt Request,FTP Request, java request , SOAP
Request
3. This tool mainly used for performance testing (load, stress)
4. GUI are very user friendly, which helps in executing and recording application sessions
5. User can apply automation frame work (data driven, parameter)
Drawbacks:
1. It does not support recording SSL (https).
2. Its only for web base application not windows base application
3. User can't write its own script, or change any recorded script