load test your drupal application scalability with apache jmeter: part two
i recently posted an introductory article on using jmeter to load test your drupal application. if you've read this article and are curious about how to build a more sophisticated test that mimics realistic load on your site, read on.
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.
an overview
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 creators
to 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 up
you 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.
and optionally:
- 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 test
you 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:
notes
the 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.resources
- jmeter user manual
- jmeter home
- jmeter binary downloads
- creating a jmeter test plan
- jmeter component reference
tech blog
- john's blog
- 2147 reads



delicious
digg
reddit
google
yahoo
Great blog. Easy to
Great blog. Easy to understand and implement (on Solaris of course!).
Hi guys - thanks for this
Hi guys - thanks for this AWESOME resource!
I have a basic question - do you have any sense of what a heavy load would look like? For example, if you get dugg, or you get slashdotted or you get tech-crunched on gigaom'd, what are we looking at in terms of traffic? Do you know what those loads typically look like, in terms of 'page requests per minute'?
Also, would love to get your thoughts on using EC2 as a back-end to deploy apps on, so scale would, in theory, be easier...
Thoughts?
it's really hard to estimate
it's really hard to estimate what kind of load you might expect. that's definitely one of the more difficult things about planning for scale; knowing what scale to prepare for.
as for ec2. trying to scale drupal on ec2 is technically more challenging than a traditional hosting provider. it's really not set up to host database driven applications.
good luck and thanks for the feedback.
True...estimating that is
True...estimating that is tough!
Pardon my ignorance here, but why do you say ec2 is not set up for rdbmses (cf your other post), or db driven apps? Is it because of the virtual infrastructure not being able to eke out the performance you might get, or is it because the motivation behind the service is to not have always-on server-type apps?
At the outset, it looks like it would make life a lot easier to gracefully scale as load grows (using your examples of scaling via load-b heartbeats and clustered dbs).
Thanks!
let's continue this
let's continue this conversation on the recent amazon blog
it i's good and useful
it i's good and useful tutorial. I am planning to test drupal 5 vs new drupal 6.
unfortunately it seems that my proxy server rarely record the cookie. Can you help me with this one ?
I use XAMPP
hebiryu, did you read part
hebiryu, did you read part two of my tutorial where i discuss cookie managers etc? i'd also recommend using firefox's cookie viewer
tools->options->privicy->show cookiesto view and manipulate your cookies. follow the steps in the tutorial carefully, watch cookies being set and unset using firefox, and you can almost certainly debug your specific problem. good luck!post new comment