Performance Testing Tips: Client Sleep Time

Posted by Grant Engle on Jul 19, 2016

In order to get actionable results from your performance tests, you need to create scenarios that closely mimic the expected behavior of your users.

After all, what good is a test if it’s not preparing you for a real-world event?

Whenever a user stops taking actions in order to think about their next move in an application, that translates to “client sleep time” in your user scenario — and it’s an incredibly important, yet often-forgotten function.


Client_sleep_time.png


Sleep is Good for You (And Your Performance Tests)

It’s very important to think about how a user interacts with your application when scripting a performance test.

Sometimes a user needs to stop and read directions, a description or documentation. Or maybe you expect them to stop and admire the beauty of your app or the images on the page.

Whatever the case, you need to factor that sleep time into your tests when you expect several users to be doing that at the same time.

For the example below, we added sleep time in the flow of users going from our homepage to our pricing page.

http.page_end("Homepage")

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

http.page_start("Pricing")

In this example, we expect users to read the content on our homepage for an average of 30 seconds before taking a look at our pricing page. Of course, no two real users are the same, so we want the virtual users (VUs) in this test to stay on the homepage for anywhere between 20 and 40 seconds.

Remember, when it comes to pretty much everything in performance test scripting: Randomization is typically the way to go!

The Load Impact User Scenario Recorder

One of our most popular tools to create realistic user scenarios is the Load Impact User Scenario Recorder, a handy little Chrome extension people use to record live actions taken in their browser. 

The recorder is a great tool to quickly create a user scenario that can be used in your load tests. But one thing people don’t always consider is their familiarity with their own applications when recording a scenario.

Think about it, you know your application and the desired user flow better than anybody. So, when you’re clicking around while using the recorder, it’s very likely you’re navigating faster than the average user — and that can be the difference between getting actionable result data and being misled by your own bias.

That’s where client sleep time comes in.

We automatically add some sleep time to each page based on the time our recorder sees you “idle” between pages, but you have complete control over the scripts you create, so make sure you go in and adjust client sleep time accordingly for every page in your test — after all, you will have the most insight into what your users are actually doing!

When it comes to planning the most realistic user scenarios, it’s always a good idea to not only think about what you expect your users to do in your app, but to go through your actual data.

Whether it’s looking at your server logs or checking out your most common behavior flow in Google Analytics, you likely have tools in place that show you what people are doing. From there, simply find the average time on page for each step, and add randomized sleep time as needed!

Recap

Adding sleep time to your load tests is another example of how knowing your users (and potential users) greatly informs your performance testing and can help produce actionable results.

If there’s one thing a lot of the developers we know could use more of, it’s sleep. So, be kind to your user scenarios and give them that luxury!

Topics: Performance testing, Chrome Extension, user scenarios, Load Testing, scripting user scenarios

Popular posts

Posts by Topic

see all