Tuesday, March 12, 2013

JMeter steps for beginners


JMeter steps

The first step you want to do with every JMeter Test Plan is to add a Thread Group element. The Thread Group tells JMeter the number of users you want to simulate, how often the users should send requests, and the how many requests they should send.
  • First select the Test Plan, clicking your right mouse button to get the Add menu, and then select Add --> ThreadGroup.
  • Click your right mouse button to get the Add menu, and then select Add --> Config Element --> HTTP Request Defaults. Then, select this new element to view its Control Panel
  • Right click on the “Thread Group” and add a recording controller: Add > Logic Controller >
Recording Controller




  • Next, select WorkBench
  • Right click on WorkBench and add the Http proxy: Add -> Non-Test Elements -> HTTP
Proxy Server

  • Return to HTTP Proxy Server, and click the “Start” button at the bottom.



Configure your brower to use the JMeter HTTP Proxy:

At this point, JMeter's proxy is running. For this exercise, we will use Iceweasel/Firefox to
view some pages on JMeter.
  • Start Iceweasel/Firefox, but do not close JMeter.
  • From the tool bar, click “Edit -> Preferences” (or “Tools > Preferences”). This should bring
up the options.
  • Select the “Advanced” tab, and “Network” tab
  • Click “Settings” button near the bottom
On the new popup, check “Manual proxy configuration”. The address and port fields
should be enabled now.
  • Address – enter “localhost” or the IP address of your system
  • Port – enter “8080”.

Record your navigation
  • With your brower, in the “Address” bar at the top, enter
  • http://jmeter.apache.org/index.html” and hit the “enter” key.
  • Click on a few links on JMeter's pages.
  • Close your browser and bring up the JMeter window.
  • Click stop in “HTTP Proxy Server”
  • Expand the thread group and there should be several samplers.


  • Select “Thread Group”
  • Right click “Add -> Listener -> Summary Report” to add an summary listener.
The summary listener will show some basic statistics.

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.

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.

Thursday, February 14, 2013

Page Cache help



It is important to specify one of Expires or Cache-Control max-age, and one of Last-Modified or ETag, for all cacheable resources. It is redundant to specify both Expires and Cache-Control: max-age, or to specify both Last-Modified and ETag.


Expires and max-age do the same thing, but in two different ways. Same thing with Last-Modified and Etag


should I do expires or max-age?

Expires depends on accuracy of user's clock, so it's mostly a bad choice (as most browsers support HTTP/1.1). Use max-age, to tell the browser that the file is good for that many seconds. For example, a 1 day cache would be:
Cache-Control: max-age=86400


If I have to also do Last-Modified or ETag, which one of those? I think I get Last-Modified

You're right, Last-Modified should be better. Although it's a time, it's sent by the server. Hence no issue with user's clock. The browser sends the Last-Modified the server sent last time it asked for the file, and if it's the same, the server answsers with an empty response «304 Not Modified»


which files should I enable browser caching for?

All files can benefit caching. You've got two different approaches:

with max-age: useful for files that never change (images, CSS, javascript). For as long as the max-age value, the browser won't send any request to the server. So you'll see the page loading really fast on the second load. If you need to update files, just append a question mark, and the date of change (for example image.png?20110602). This way you can make files expire if it's urgent (remember that the browser almost never hits the server once it has a max-age file). Main use is to speed things up and limit requests sent to the server.
with Last-Modified: can be set on all files (including those with max-age). Even if you have dynamic pages, you may not change the content of the file for a while (even if it's 10 min), so that could be useful. The main use here is to tell the browser «keep asking me for this file, if it's new, I'll send you the new one». So, there's a request sent on each page load, but the answer is empty if the file is already good (304 Not Modified), so you save on bandwidth.
The more you cache, the faster your pages will show up. But it's a difficult task to flush caches, so use with care.

A good place to learn all this with many explanations: http://www.mnot.net/cache_docs/

ad