Jmeter used to playback Apache access logs to generate live-like server load Jmeter is a very useful tool for not only performance tests but also for automation of all sorts of web tests. Its not as powerful as selenium when it comes to ajax etc but it still allows to login, keep session and execute any sequence of http calls.
In addition to ab (apache benchmark) and curl it comes in handy when you want to stress test your applications to see the capacity and possible bottlenecks.
Its difficult to perform reliable tests when your development environment does not mirror live and when you have no traffic at all. 10000 home page calls will perform differently depending on what is the server doing.
To generate realistic load and be able to profile applications and their bottlenecks you can playback your live server logs on test machines.
Access log will not be 100% accurate especially if you have a lot of forms and POST requests but for sites that operate mostly on GETs you can mimic the live traffic very well.
1. To acheive that we install latest Jmeter (its a java application).
2. Then we create thead group (each thread group will execute one after another), it might be much faster if you add more than one thread. It will also put more load on the server as many concurrent request will be sent. Do not put too many thought as yout client machine with jmeter may become bottleneck in that test ;- ) 5-10-20 should be ok on any modern machine if you put 50 .... you have to check local load.

3. We add sampler -> access log sampler

4. Set url and pick order preserving log parser
5. Pick Session Filter which will make your requests more realistic. Each log entry has cookies sent with request. Session filter will send them along with request so the GET will be exactly the same as real call.

6. Finally point file to the log file in apache combined format like this:
71.76.111.111 - - [04/Apr/2009:05:02:04 -0400] "GET /someurl?type=value HTTP/1.1" 200 408 "http://someurl.com/somepage" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)" "cookienameone=SOMEQAVLUE; PHPSESSID=7c5562156f892272c6801d0e3111111"
7. Attach some reports listners like aggregated report and results tree and graph

Run and behold.

There is a nice thing that you can ignore all images by selectin parse images = false in sampler config. Unfortunately it will still submit posts and flash movies etc.
You can easily filter your log files to get rid of all that garbage and make them tenth of their size in the same time. You can run this kind of script to get rid of urls you want to ignore. Just be carefult as url can be in the referer as well so make sure if keep that in mind while filtering more and more urls out.
#!/bin/bash file=$1 cat $file | \ grep -v '\.gif' | \ grep -v '\.png' | \ grep -v '\.jpg' | \ grep -v '\.jpeg'| \ grep -v '\.ico' | \ grep -v '\.css' | \ grep -v '\.js' | \ grep -v '"POST' | \ grep -v '\.swf' > filtered.$file
Main Blog Categories
About the author

Hi, my name is Artur Ejsmont,
welcome to my blog.
I am a passionate software engineer living in Sydney and working for Yahoo! Drop me a line or leave a comment.
Enjoy!
Comments
Thanks. This is exactly what
Thanks. This is exactly what i want. Happy Valentines Day :)
Post new comment