scripting - How do I create a user scenario that includes multiple pages on my website and emulates realistic user behaviour? -


we’ve come across question @ load impact, thought i’d add stack overflow community make easier find:

i want load test realistic. how create load impact user scenario emulates realistic user behaviour, accessing different pages , accessing pages more (for example home page), real users would?

if have 3 pages on site users can visit, , know how many times each page visited users, can calculate “weight” of each page, , create user scenario simulates same kind of visitor pattern on site real users exhibit. example of how that.

first, have find out how popular each of 3 pages are. can done looking @ statistics e.g. google analytics see how many times each page visited last month or so. let’s have these figures:

==== page ====    ==== visits/day ==== /                 8453 /news.php         1843 /contacts.php     277 

the total number of page visits 10573 (8453+1843+277). if divide each individual number total, “weight” (percentage) particular page – i.e. how big chance random page load on site happens load particular page:

==== page ====    ==== visits/day ====    =========== weight =========== /                 8453                    0.799 (79.9% of page loads) /news.php         1843                    0.174 (17.4% of page loads) /contacts.php     277                     0.026 (2.6% of page loads) 

now can create our user scenario replicates real traffic on our site – i.e. exercise our web server in same way real users do. here code:

-- create functions each of 3 pages. calling 1 of these functions  -- result in simulated client loading resources necessary rendering -- page. i.e. client perform 1 page load of particular page. -- -- main/start page local page1 = function()     -- first load html code     http.request_batch({         "http://test.loadimpact.com/"     })     -- when html code done loading, start loading other resources     -- referred in html code, emulating load order real browser uses     http.request_batch({         "http://test.loadimpact.com/style.css",         "http://test.loadimpact.com/images/logo.png"     }) end -- -- /news.php page local page2 = function()     -- example page consist of 1 resource - main html code page     http.request_batch({         "http://test.loadimpact.com/news.php"     }) end -- -- /contacts.php page local page3 = function()     -- example page consist of 1 resource - main html code page     http.request_batch({       "http://test.loadimpact.com/contacts.php"     }) end -- -- -- random page load, using our page weights found out earlier -- -- generate value in range 0-1 local randval = math.random() -- find out page load if randval <= 0.799     -- 79.9% chance load page1     page1() elseif randval <= (0.799 + 0.174)       -- 17.4% chance page2 gets loaded     page2() else     -- ...and rest of time (2.7%), page3 gets loaded     page3()   end 

Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -