Jmeter load distribution - jmeter

How to emulate different loads from LG's for single thread group (i.e My First LG should emulate only 200 users, second LG should emulate 50users and my third LG should emulate 250 users)
IS it possible in Jmeter?

If you use distributed testing - you can take the following approach:
Define number of virtual users in the Thread Group using __P() function as ${__P(users,)}
On your load generator machines locate user.properties file (it lives in /bin folder of your JMeter installation) and add the following line to it:
users=200 - on the 1st LG
users=50 - on the 2nd LG
users=250 - on the 3rd LG
etc.
See Apache JMeter Properties Customization Guide for more information on JMeter properties and ways of setting and overriding them.

Related

Jmeter load distribution using single thread group

I have a single thread group for 100 users and I need to distribute the load as below 100 users will navigate to login>> homepage. After that 60 users navigate to buy shoes and the remaining 40 users will check their balance and 100 users log out. How can we achieve this in JMeter?
I am trying If controller to achieve this but cannot do so.
Take a look at Throughput Controller, it allows you to specify either percentage or exact number of executions of its children.
If you will have more distribution options Weighted Switch Controller might be a more convenient option:
The Weighted Switch Controller can be installed using JMeter Plugins Manager

JMeter Selenium test always using 1 thread

I want to start testing my JMeter scripts on my website using selenium,
If I follow the tutorial it state that it works only using 1 thread
DO NOT change the "Thread Group" values. They must all be set to 1.
Do I have a limit of running selenium test using 1 user per computer at a time?
I found also answers about selenium that it can be done, but not recommended. just want to make sure it shouldn't be done and keep executing 1 thread in JMeter + Selenium test.
Looking into Web Driver Tutorial:
Note: It is NOT the intention of this project to replace the HTTP Samplers included in JMeter. Rather it is meant to compliment them by measuring the end user load time.
So it is recommended to create the main load using JMeter's HTTP Request samplers and use one (or several) WebDriver Samplers to measure scripts execution time, rendering speed, etc.
Also pay attention to the quote from the 10 Minute Guide
Each browser consumes a significant amount of resources, and a limit should be placed on how many browsers the reader should create.
From experience, the number of browser (threads) that the reader creates should be limited by the following formula:
C = N + 1
where C = Number of Cores of the host running the test
and N = Number of Browser (threads)
eg, if the current reader's host has 4 cores, the formula would yield:
4 = 3 + 1
meaning that the script should have a MAXIMUM of 3 threads.
Also check out the memory footprint for a single browser accessing your application.
So theoretically you can kick off one browser per each CPU core after 1st and allocate around 1 GB of RAM for your browser (this may vary depending on how "heavy" your page is.
Check out The WebDriver Sampler: Your Top 10 Questions Answered for more details on Selenium and JMeter integration.

Increase number of threads in JMeter during execution

I have a performance test in JMeter and would like to test maximum system performance/throughput with it. So number of active threads should be increased for example while Error rate is under 2 %. I found Constant Throughput Timer, put it into Thread Group but it only pause or slow down threads. I tried define it as follows, with a property: ${__P(throughput,)}, but not sure what should be correct value for this property. I can't see how JMeter could measure system maximal performance.
There is no Out of the box solution as of JMeter 3.3, see this enhancement request:
https://bz.apache.org/bugzilla/show_bug.cgi?id=57640
Still it is possible to dynamically add threads since JMeter 3.2 (see https://bz.apache.org/bugzilla/show_bug.cgi?id=60530) in a JSR223 Test Element using JMeterContext:
ctx.getThreadGroup().addNewThread(delay, ctx.getEngine());
So based on this, you could in a JSR223 Test Element (Pre/Post Processor or Sampler) check the presence of a file in a folder of your choice named :
NUMBER_OF_THREAD_TO_ADD.txt
If present, use its name to compute number of threads and call this method.
There is no such functionality in the "vanilla" JMeter howere it is possible with plugins, check out:
Concurrency Thread Group
Throughput Shaping Timer
They can be connected together via feedback loop so Concurrency Thread Group will add more threads if needed to reach the desired number of requests per second.
You can install both the plugins (and keep them up-to-date) using JMeter Plugins Manager

Jmeter Find Data Ussage Per Request

I have build a jMeter test for a mobile web application. The test works perfect and i would see how much data a request cost for the mobile data bundle of the user. Is it possible ?
For downloaded data there are 2 ways to achieve this:
Approximation of downloaded data: Summary Report has
Avg. Bytes - average size of the sample response in bytes.
You could use its value to approximate how much data is downloaded by summing up # Samples x Avg. Bytes over all requests.
If you want more precision, and estimation of both uploaded and downloaded data, you can use one of the programmable listeners (BeanShell listener, BSF Listener or JSR223 Listener) and collect this stats by yourself: they all have access to SampleResult, which allows you to collect the size of the uploaded data (sampleResult.getSamplerData().length()) and the size of the downloaded data (sampleResult.getHeadersSize() + sampleResult.getBodySize()). You can then write this data into file (this is an example for BeanShell)
Add next 2 lines to user.properties file (it is located under /bin folder of your JMeter installation)
jmeter.save.saveservice.print_field_names=false
jmeter.save.saveservice.bytes=true
It will "tell" JMeter to store response size and also adds a header to generated .jtl file when you run your test in command-line non-GUI mode so you could figure out which columns stands for which metric.
You'll need to restart JMeter to pick the properties up.
You'll get something like:
So you will be able to use Excel or equivalent to sum all the "bytes" lines up and calculate the associated cost.
See Apache JMeter Properties Customization Guide for more information on what else can be controller with JMeter properties and what needs to be done to apply the changes.

Using Variable for Thread group Ramp up time

how to configure the thread group ramp up time with a jmeter variable, I tried for both number of threads and ramp up time. No of threads is working fine, but ramp up time takes the default value 1 and the variable value doesn't take effect, Appreciate any help
You cannot use variables in Thread Group setting as Thread Groups are initialised during startup, before any variables are read.
If you need to make number of threads and/or ramp-up period configurable use __P() function like:
${__P(threads,)}
${__P(rampup,)}
Aforementioned threads and rampup properties can be defined in several ways:
If you run JMeter in command-line non-GUI mode you can pass the properties via -J command line key as
jmeter -Jthreads=50 -Jrampup=30 -n -t /path/to/your/testplan.jmx
The same approach will work for GUI mode, however it is not recommended to use GUI for load test execution as it is quite resource consuming and may ruin your test.
You can define these properties in user.properties file (located in /bin folder of your JMeter installation) as:
threads=50
rampup=30
After restart JMeter will pick the properties up and you will be able to refer them via __P() function as described above.
See Apache JMeter Properties Customization Guide for comprehensive information on various JMeter properties and ways of working with them
There is no reason why it works for # of threads but doesn't work for ramp-up time. I've been using configurable properties for both with success.
1 is the default value in JMeter if variable can't be resolved properly. You likely made a typo. To investigate the problem, you may want to use 'Property Display' element (right-click WorkBench / Add / Non-Test Element / Property Display).
If this doesn't help, please post link to the screenshot of thread group, and relevant part of your config where you define the ramp-up time variable.
EDIT : example
This is the way I usually work with configurable properties stored in external files (and it works for ramp-up as well):
define user defined variable on test plan level, e.g. someVarName is ${__P(someVarName)}
then use this var e.g. in ramp-up as ${someVarName}
You cannot use variables for those values, only properties:
http://jmeter.apache.org/usermanual/functions.html
Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.

Resources