load test your drupal application scalability with apache jmeter: part two
the previous article showed you how to set up jmeter and create a basic test. to produce a more realistic test you should simulate "real world" use of your site. this typically involves simulating logged-in and logged-out users browsing and creating content. jmeter has some great functionality to help you do this.
as usual, all code and configurations have been tested on debian etch but should be useful for other *nix flavors with subtle modifications. also, although i'm discussing drupal testing, the method below really applies to any web application. if you aren't already familiar with jmeter, i'd strongly recommend that you read my first post before this one.
the http protocol exchanges for realistic tests are quite complex, and painful to manually replicate. jmeter kindly includes http-proxy functionality, that allows you to "record" browser based actions, which can be used to form the basis of your test. after recording, you can manually edit these actions to sculpt your test precisely.
our test - browsers and creators
as an example, let's create a test with two test groups: creators and browsers. creators are users that arrive at the site, stay logged out, browse a few pages, create a page and then leave. browsers, are less motivated individuals. they arrive at the site, log in, browse some content and then leave.
setting up the test - simulating creatorsto create our test, fire up jmeter and do the following.
create a thread group. call it "creators". add a "http request defaults" object to the thread group. check the "retrieve all embedded resources from html files" box.
add a cookie manager to the thread group of type "compatibility". add an "http proxy server to the workbench", as follows:
modify the "content-type filter" to "text/html". your jmeter-proxy should now look like:
navigate in your browser to the start of your test e.g. your home page. clear your cookies (using the clear private data setting). open up the "connection settings option" in firefox preferences and specify a manual proxy configuration of localhost, port 8080. this should look like:
note: you can also do this using internet explorer. in ie7 go to the "connections" tab of the internet options dialog. click the "lan settings" button, and setup your proxy.
start the jmeter-proxy. record your test by performing actions in your browser: (a) browse to two pages and (b) create a page. you should see your test "writing itself". that should feel good.
now stop the jmeter-proxy. your test should look similar to:
setting up the test - simulating browsers
create another thread group above the first. call it browsers. again, add a "http request defaults" object to the thread group. check the "retrieve all embedded resources from html files" box.
add a cookie manager to the thread group of type "compatibility". start the jmeter-proxy again. record your test by performing actions: (a) login and then (b) browse three pages. your test should look like:
stop the jmeter-proxy. undo the firefox proxy.
setting up the test - cleaning upyou can now clean up the test as you see fit. i'd recommend:
- change the number of threads and iterations on both thread-groups to simulate the load that you care about.
- modify the login to happen only once on a thread. see the diagram below.
- rename items to be more meaningful.
- insert sensible timers between requests.
- insert assertions to verify results.
- add listeners to each thread group. i recommend a "graph results" and a "view results tree" listener.
your final test should look like the one below. note that i didn't clutter the example with assertion and timers:
running your testyou should now be ready to run your test. as usual, click through to the detailed results in the tree to verify that your test is doing something sensible. ideally you should do this automatically with assertions. your results should look like:
notesthe test examples that i chose intentionally avoided logged-in users creating content. you'll probably want these users to create content, but you'll likely get tripped up by drupal's form token validation, designed to block spammers and increase security. modifying the test to work around this is beyond the scope of this article, and probably not the best way to solve the problem. if someone knows of a nice clean way to disable this in drupal temporarily, perhaps they could comment on this article.
- jmeter user manual
- jmeter home
- jmeter binary downloads
- creating a jmeter test plan
- jmeter component reference