How to Randomize URLs in Your Load Tests

Posted by Load Impact on Sep 5, 2018

You’ve run your baseline load tests and you’ve tracked what you think is regular user behavior with browsing, shopping carts, checkout and the like. But as experienced developers, we know one thing: there’s no such thing as “regular user behavior.” So when you’re ready to take your load testing to the next level, try this script showing you exactly how to randomize URLs in your load tests.

regular user behavior

Your random URL testing process looks like this:

  1. Create a list of URLs you want tested
  2. Create your Load Impact script to randomly select URLs from that list
  3. Run your load tests with that script
  4. Evaluate, adjust, and repeat

Step 1: Create a list of URLs to test

It would be unwise and impractical to hit *every* possible URL permutation on your site. (There are other tools for URL testing.) Instead, create a list of URLs you want tested. You may know this offhand - if so, great. Perhaps your site is small enough you can test all of the possible pages easily.

Another option: check your Google Analytics data for all URLs visited during a particular period (you choose based on the number of URLs - maybe the past month, quarter or even year). You can export the “pages visited” report.

To use this list of URLs in your test, you’ll need to first create a CSV, then upload it to Load Impact’s data store feature. Here’s how.

Your CSV is simple: it’s just a list of the URLs you want visited with each URL on a separate line. Then, upload that CSV to a Load Impact Data Store. (Complete details are in this support article). In short, you’ll upload a Data Store, approve its format, and then simply make sure you’ve made note of the data store name - you’ll need it for the script in the next step.

Step 2: Create your Load Impact script

The following script example is pretty straightforward, but we’ll add a few notes after the code:


-- Seed RNG

-- Open data store (this data store should have one URL per line)
dsname = "URL data store"
ds =

-- Create parameters for http.request_batch() to load 5 random URLs
batch_params = {}
for i = 1, 5 do
 url = ds:get_random()
 table.insert(batch_params, {"GET", url[1]})

-- Perform HTTP requests as a single batch request
-- (This means the simulated client will behave like a browser and try to fetch several things in parallel)

local responses = http.request_batch(batch_params)

-- Simulate user think time before script is reiterated
sleeptime = 100 + math.random(100)

Note that in line 5, you’ll replace the “URL data store” with the name of your Data Store you uploaded in Step 1. In line 10, of course, you can choose more than 5 URLs to test in the script, but given browser limits and usual behavior, 5 is a good number to start with.

(The script is also available in this support article)

Step 3: Run your Load Tests

Since you’re an experienced Load Impact user, you already know the basics - you’ll just create a new test, then add your new random URL script user scenario. Then run your tests.

Step 4: Evaluate, adjust, and repeat

As with every test, we recommend you run it continuously and consistently. You may want to include some of your random URL tests in your regular deployment pipeline. You may also want to run a deeper test at regular intervals. No matter which you choose, have fun with the random URL script, and, as always, happy testing!

Topics: Load Impact 3.0, Load Testing, load impact, randomize URLs, Performance testing

Recent Posts

Popular posts

Posts by Topic

see all

Subscribe to Email Updates