Re: Multi Threading Issue When executing Jmeter with Selenium

Dmitri T <[email protected]> Wed, 3 Jan 2024 10:36:38 +0100
Newsgroups gmane.comp.jakarta.jmeter.user
Message-ID <PH7PR12MB713930F426CC8D1ED405DF45C060A@PH7PR12MB7139.namprd12.prod.outlook.com>
Ramesh Raja wrote:
> Hi Team,
>
> We're trying to use Jmeter and Selenium for performance testing. When we
> run scripts with one thread, the execution succeeds; however, if we run the
> scripts with five threads, two or three of the threads fail every time
>
> We tried with reducing the ramp-up time and made use of the Selenium Grid
> feature.yet having the same problem.
> --
> Thanks & Regards,
>
> *Ramesh Raja*
>
> [email protected]
>
Unfortunately your "fail" statement doesn't tell the full story, you 
need to share at least response message and jmeter.log file 
<https://jmeter.apache.org/usermanual/get-started.html#logging>contents 
so we could understand what's going on. Also it's not very clear how do 
you integrate JMeter with Selenium. If you use some custom Groovy code 
in JSR223 Samplers- make sure that it's thread-safe 
<https://www.baeldung.com/java-thread-safety> and you're not re-using 
the same WebDriver instance by multiple threads.

Also be aware of WebDriver Sampler 
<https://jmeter-plugins.org/wiki/WebDriverSampler/> plugin which 
provides JMeter integration with Selenium and it's suitable for 
multi-threaded execution.

And last but not the least, using real browsers for load testing is not 
recommended by either Selenium developers 
<https://www.selenium.dev/documentation/test_practices/discouraged/performance_testing/> 
or WebDriver Sampler developers 
<https://jmeter-plugins.org/wiki/WebDriverTutorial/>, you should be 
using HTTP Request 
<https://jmeter.apache.org/usermanual/component_reference.html#HTTP_Request> 
samplers to create the main load (make sure to configure JMeter to 
behave like a real browser 
<https://guide.blazemeter.com/hc/en-us/articles/206733719-How-to-make-JMeter-behave-more-like-a-real-browser>) 
and i.e. 1 instance of WebDriver for checking the frontend performance.