Make Your Load Tests More Realistic

Posted by Load Impact on Jan 29, 2018

Testing, by its nature, isn’t the real world. Still, you can make your load tests more realistic. Besides following our general advice about better load tests - like using the LoadImpact plugin for Google Chrome to record user scripts that emulate frequently-used features - we’d like to suggest another tips that might make your tests even better.

More Realistic Client Script Behavior

As we mentioned, creating a client script is the best way to simulate real user behavior. But you can make those load tests even more realistic when you go a step further to emulate that user behavior.

Let’s say, for this example, that you run a premium paper clip e-commerce site. Customers love your premium paper clips (especially the ones shaped like kittens). So when you record a script that mimics user behavior, you might have the simulated user click through product listings, add some popular products to a cart, and go through the checkout process. Yet, in the real world, that sequence won’t take place in a rapid, click-click-click manner.

Instead, a real user will be distracted by phone calls, Slack, email, coffee breaks, and perhaps even real kittens (not just kitten-shaped paper clips).

Those distractions cause a gap in the user’s actions on your site. We call those gaps “client sleep time.” And, guess what: you can insert varying client sleep times between actions in your script, thus making your scripts and tests more realistic.

realistic.jpg

Adding Client Sleep Time To Your Scripts

Here’s how: Edit your LoadImpact user script and look for this command:

http.page_end(“Page_X”)
client.sleep(x)

To randomize the sleep time on a page, edit that client sleep function. We suggest you try different variations of this randomized function:

client.sleep(math.random(20, 40))

In this example, the client sleep time would be an average of 30 seconds, with the minimum at 20 seconds, and the maximum at 40 seconds. Depending on the length of time you have to actually let your tests run, you might try increasing or decreasing those numbers.

In a pinch, you can go with our default suggestion. But to make your load tests truly realistic, you can dig a little deeper. For example, looking in your Google Analytics logs - or other site data, you may have noticed that the average time for a user to go from login and browsing to checkout on your site is 30 minutes. With a little more digging, you might find that while the average is 30 minutes, many take more than an hour, and a few up to 18 hours.

This is just an example, of course, but let’s think about the user behaviors that might lead to such a discovery. Perhaps users are interrupted, and a five-minute ecommerce task takes 30 minutes thanks to a busy office. Or a non-urgent paper clip reorder sits in an open tab overnight until the user has a chance to get back to finishing the order.

Client sleep times of 30 minutes - or 18 hours - aren’t realistic for your regular daily build tests. We certainly don’t recommend long, random client wait times as part of your CI / CD (continuous integration or continuous delivery) automation. But when you’re doing a less frequent stress test, or looking to push your site to its limits before a particularly busy season, it’s worth investing the time to run some of these more realistic scripts and thus getting even more realistic results than you’ll see with the early indicators in your daily tests.

Give the client wait time scripting a try - and see what you discover.

Happy testing!

Topics: Performance testing, Load Testing, realistic load test

Popular posts

Posts by Topic

see all

Subscribe to Email Updates