Search code examples
performanceselenium-webdriverjmeterperformance-testingload-testing

Jmeter - How to load test ajax web applications by multiple users with cache


I have been using Jmeter for performance testing my web application. I have recorded the jmeter script by excluding js,css and other static content files. While running the script, Jmeter doesnt execute javascript files so ajax XHR request are not sent. To overcome this i have recorded the script with js, css and other static content and it recorded all the Ajax xhr request too. But the performance results seems to be different from the browser loading time. Also i need to use cache during my performance testing.

Below is how my test plan will look like,

  1. Included Retrieve all embedded resources in HTTP Request manager.
  2. Concurrent pool size is 6
  3. I have added HTTP cookie manager and Cache manager.
  4. I have added a loop controller (This is for caching, jmeter will cache the files on first iteration and it will use the cached files after that)

The problem i am facing is that the time taken for rest call are double the time shown in the browser console for single user. I have tried all other combinations but always i am getting higher time than the browser console.

I have tried to use the Selenium webdriver plugin to simulate the browser behavior but it doesnt seems to be using the cache. (https://www.blazemeter.com/blog/how-load-test-ajaxxhr-enabled-sites-jmeter)

Is there any other way to solve this problem? I want to take the metrics with cache so kindly suggest me any solution that must include cache. Or is there any other tool similar to jmeter that could solve this issue. My goal is to take web page load time with cache for 'n' number of users.

PS : I am even interested to write any scripts in jmeter but the scripts should not overload the performance of jmeter.

Thanks in advance.


Solution

    1. You should not be recording calls to embedded resources (images, scripts, styles, fonts, etc.) as if you record them - they will be executed sequentially while real browsers do this in parallel. So remove recorded requests for the embedded resources and "tell" JMeter to download them (and do it in parallel) using HTTP Request Defaults
    2. You should be recording AJAX requests, however real browsers execute them in parallel while JMeter runs them sequentially. In order to make JMeter's behavior closer to real browser you need to put these AJAX calls under the Parallel Controller

    You can install the Parallel Controller extension using JMeter Plugins Manager

    JMeter plugins manager - parallel controller