April 1, 2020
Estimated Post Reading Time ~

How to Use Google Chrome Headless to create a Realistic but Simple Load Test

A web page is not only an HTML page, but also lots of additional embedded resources such as images, web fonts, .css and .js files A simple load test using curl will only request the HTML page, but not the embedded resources. If you hard-code the additional calls to the embedded resources as curl commands, your code runs the risk of becoming obsolete quickly when the web page changes. This latter issue also afflicts load testing tools that allow you to record all of the calls involved in the loading of the single web page as a single, complete transaction (JMeter, LoadRunner, etc.).

An obvious solution is to hire multiple people to use real browsers to test. This is not practical. Google Chrome got a headless feature in version 59 which can be invoked from the command line on instances without a windowing subsystem. Watch this YouTube video.

On Windows 10, here’s the command that will load not only a we-retail web page but also all of its embedded resources. Note that the --disable-gpu argument is only needed for Windows, not MacOS or Linux. Verify by tailing AEM’s request.log

“C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” --headless --disable-gpu http://localhost:4503/content/we-retail/us/en.html

You can now build yourself a decent and realistic load test by writing a bash shell script or a Windows PowerShell script to repeatedly load a set of web pages from a CSV file, and run this from multiple instances. Here is how to invoke [Google Chrome Headless] in PowerShell:

Start-Process ‘C:\Program Files (x86)\Google\Chrome\Application\chrome.exe’ “--headless --disable-gpu http://localhost:4503/content/we-retail/us/en.html”

A single instance can be used to generate multi-user load by simultaneously running multiple instances of PowerShell or bash. Below is a table of the results of a 4-user, 1-hour load test on the complete set of we-retail pages (399 pages). You can download the Excel spreadsheet here (note that it has multiple worksheets).


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.