2

I am trying to setup a JMeter load test, using the Recording Controller.

This results in duplication of all the calls the web browser would make - including css files, js files and images.

Given that a web browser would get these concurrently (performing approximately 10 web requests concurrently). The jmeter documentation tends to equate 1 user to 1 thread - but this does not line up with the way in which modern web browsers work.

Do I need to use 10 threads for each user when setting up my load test?

Alan Wolman
  • 673
  • 4
  • 16

2 Answers2

5

Strictly Speaking, JMeter can't simulate a browser. JMeter has its own limitations, like not parsing .js files (as per 3.0 version), sending ajax requests from events etc.

But, for your question, there is support in JMeter.

enter image description here

So, you can specify the concurrent pool size as per your requirements, say concurrent pool size value set to 10, which would solve your issue.

Today browser normally sends requests concurrently and each browser has its own max value for maximum connections that can be made concurrently.

Refer following links: Max parallel http connections in a browser? and How to solve Chrome's 6 connection limit when using xhr polling.

When you use "Retrieve Embedded Resources" and set Concurrent Pool Size, you ONLY need to add parent sampler, which triggers resource requests like .css, .js files by Jmeter itself. (Eg: add only stackoverflow.com and it will load all the resources like .css, .js automatically). During recording , all these requests are seperately recorded, so you need to remove all of them or create a new plan/thread group containing only parent sampler.

Note: As I mentioned, requests triggered from .js, .csv won't be sent as Jmeter won't parse them like Browser. You need to add ONLY these requests as samplers explicitly. Add View Results Tree and compare the requests triggered by Jmeter and Browser (F12 -> Network tab) to know which request are missing by Jmeter.

Community
  • 1
  • 1
Naveen Kumar R B
  • 6,248
  • 5
  • 32
  • 65
3
  1. First of all, don't record requests to embedded resources. If you click Add Suggested Excludes button the HTTP(S) Test Script Recorder will automatically populate a regular expression to filter images, scripts and styles.

    Suggested Excludes

  2. Second. To simulate browser behaviour: 1 main request to the page and several parallel requests to retrieve content you can use "Advanced" tab of the HTTP Request Sampler (or even better HTTP Request Defaults). You can also limit embedded resources to your application under test domain there

    HTTP Request Defaults

  3. Real browsers download images, styles and scripts. However well-behaved browsers do it only once, on subsequent requests these entities are being returned from cache. So make sure you add HTTP Cache Manager to your Test Plan to represent browser cache so you could avoid overwhelming your server with extra requests which don't happen in the reality.

See How To Make JMeter Behave More Like A Real Browser for more detailed explanation and instructions on using aforementioned Test Elements

Dmitri T
  • 159,985
  • 5
  • 83
  • 133