Stress test your Flex application using Jmeter and EC2 - Part 1

A while back, a client needed to stress test his application.
Since I had some experience with JMeter before, and was eager to try out Amazon’s EC2 (Elastic Compute Cloud), this was the setup I offered.
Turns out it worked remarkably well.

Detailed explanation and utility files/scripts follows…
In part 1 we'll discuss Jmeter configuration in detail.
In part 2 we'll go over the configuration procedure of EC2, and how to run the test on a distributed environment.


* Note: the information below was gathered from a myriad of blogs, forums and hectic googling. Unfortunately, I don’t remember what information I got where, so apologies if you read this and think I reaped you off – please contact me and I’ll add the proper credit.


And now, on with the show!

So, you want to run a Jmeter scenario on cloud computing….


First, lets create a Jmeter scenario:
  1. Download Jmeter from and unzip it (say c:\jmeter).
  2. Edit jmeter executable and modify HEAP variable to whatever you like (-Xms1024m -Xmx1024m)
  3. Run Jmeter by running c:\jmeter\bin\jmeter and you’ll see the Jmeter gui with the basic scenario tree – TestPlan and Workbench.
We need to setup Jmeter to be able to record a scenario.

We’ll use a proxy to record a test plan.

Note, that Jmeter does not support HTTPS. Since HTTPS is secure, the proxy is unable to decrypt the traffic and record the request parameters or cookies.

  1. Select “test plan” on the tree
  2. Right click on the “test plan” and add a new thread group: add -> thread group
  3. Select the thread group
  4. Right click “add -> config element -> Http Request Defaults”
  5. Protocol – enter “HTTP”
  6. Server name – enter the host name
  7. Path – leave blank
  8. Port number – enter “80”
  9. Right click on workbench and add the Http proxy: add -> non-test elements -> Http Proxy Server
  10. Port field – Enter “9090”
  11. Target Controller – click on the drop down and select “test plan > thread group”
  12. Click the “add” button in “Patterns to include”. This will create a blank entry.
  13. Enter “.*”
  14. right click the proxy server → add → timer → gaussian random timer.
  15. In the constant field enter ${T} and in the deviation enter a number in millisecs (i.e. 500).
  16. Click the “start” button at the bottom
  17. Start Internet Explorer, but do not close Jmeter.

As a general tip, it is a good idea to set the homepage for your browser to a blank page. This way, it reduces the number of unwanted pages Jmeter records during the session. It is a good idea to try the proxy with different sites and get comfortable with different filtering patterns. Also, close all programs like messenger, pidgin etc. that use the same proxy settings as IE, as that will add junk to the scenario.

  1. From the tool bar, click “tools -> internet options”. This should bring up the options.
  2. Select the “connection” tab
  3. Click “lan settings” button near the bottom.
  4. On the connections tab, check “Use a proxy server for your LAN”. The address and port fields should be enabled now.
  5. Address – enter “Localhost” or the IP address of your system
  6. Port – enter “9090”.
  7. Click “ok” button
  8. Click “ok” button again. This should return you to the browser

You’re done with Jmeter and IE setup – Woohoo!
Now, we’ll record the scenario:
  1. In the “Address” bar at the top, enter the url to record and hit the “enter” key.
  2. Do the actions you want to be recorded.
  3. Close internet explorer and bring up the Jmeter window.

You’re done with the recording phase! Aren’t you happy?

Let’s review the test plan

To be able to see statistics on the scenario, we’ll add some reports.

  1. Select “thread group”
  2. Right click “add -> listener -> aggregate report” to add an aggregate listener. The aggregate listener will show some basic statistics.
  3. Select the aggregate report
  4. You can configure a filename to specify where to dump the report data, filter only errors, successes, all or none, and configure what data is displayed.
  5. Select “thread group”
  6. Right click “add -> listener -> summary report” to add a summary listener.
  7. You can set the same settings as you did for the aggregate report.

Note: Some HTTP POST requests chain multiple argument sets with ‘\n’. Jmeter misunderstands this and does not play the scenario properly. In this case, you will have to manually edit the resulting scenario JMX file and split those into separate requests.

Ready…. Set…. GO!
  1. To run the scenario, select “thread group”
  2. Number of threads – the number of “virtual users” Jmeter will emulate. There will be a thread running the scenario for each virtual user.
  3. Ramp up Period – the time to wait before starting a new virtual user.
  4. Loop count – the number of times to repeat.
  5. Run → Start to start running.


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 gray.


Note: To launch scenario in a distributed configuration, start each jmeter server as jmeter- server,
and run the managing instance as: jmeter -n -t <scenario.jmx> -l <log.jtl> -RserverInstance1,serverInstance2… &


What’s next in Part 2: Setting up Amazon EC2.