Scale thread count by scaling factor - jmeter

How would I do multiply two constants or variables .
I have a number of Thread groups in a Jmeter test each with a variable number of threads. I would like to multiple each threads Thread group by a constant factor , so I could run tests with different percentage of threads .
I have tried defining a scale factor as ${__P{scale,1}} so that I could multiply a constant thread count with the scale as 100 * ${__P{scale,1}} , but Jmeter doesn't seem to recognize that.

Of course it doesn't, you need to wrap your expression into i.e. __groovy() function.
Example syntax:
${__groovy(100 * org.apache.jmeter.util.JMeterUtils.getPropDefault("scale"\, 1),)}
More information:
JMeterUtils JavaDoc
Apache Groovy - Why and How You Should Use It

Related

Thread scoped variable counter

Looking to create a jMeter script with thread-local counter. I have a pool of 50000 (1 to 50000) keys and would like to spread them evenly over the number of threads in a threadGroup. Seems like I could do a simple calculation up front and create a min and max variable (ie: if I had 100 threads and my ${__threadNum} was 2 ... I would be looking at a __counter range of 501 to 1000. Is there a way to do that calc up front and then just run an efficient thread-scoped variable or function to loop thru the keys within the range for that thread (obviously next run could be 50 threads or 200). Thanks,

2 http requests on jmeter - each 50% of the time

I'm trying to create a jmeter script that sends 2 http requests(each with a different path). I managed to get it to send the requests randomly, but i also need it to send each request exactly 50% of the time. any ideas?
Divide your requests into 2 separate Thread Groups. Set identical number of Threads and Loops in each Thread Group
Put 2 requests under the same Thread Group. Add Throughput Controller as a child of each request and either set the same "Total Executions" value for both Throughput Controllers or use 50.0 value in "Percent executions" mode.
See Running JMeter Samplers with Defined Percentage Probability article for detailed information on above approaches and for more complex distribution scenarios.
Option 1: Math
Run a large number of users or a large number of times, picking randomly. On average, it's 50% of the time. Easiest to do, but not exact.
Option 2: Alternate
Use a variable to alternate a single thread back and forth over the course of multiple loops. I assume you have some sort of If Controller that you're using to split them. In your condition, use "${alternating_variable}"=="1". Then use a Beanshell Postprocessor to switch its value: vars.put(alternating_variable,2);. Obviously, you'll need the reverse for the other HTTP Request (both the If and the Beanshell). A little involved, and requires a thread to loop multiple times.
Option 3: Determined by Thread Number
Inside your If, use ${__threadNum}%2!=0 and ${__threadNum}%2==0. This gets the number of the thread, divides by 2, and compares the remainder to 0. Any even-numbered thread will go into one If and any odd thread will go into the other. Easy now that it's generated, but requires multiple threads. Also not necessarily easy to understand.
Apply 2 throughput controller and place your first http request into first throughput controller and 2nd request in other controller. Now change the mode to Percent Executions and pass 50 in throughput textbox
Please refer this
link for more details

How to calculate the number of threads and loop count in jMeter

I am not able to find out the specific answer of how to calculate the number of threads for running a load test in JMeter?
How to identify the loop count ?
Is there any formula?
What are the parameters to consider for the calculation?
Say if you want to fire 100 request to server with 2 tps. then your threas properties should be like below:
Number of threads(users) :2.
Ramp up period: 100
Loop count :50
Based on above example.Please find below explaination.
• Number of Threads (N): Sets the number of threads the JMeter will use to execute our test plan. We must know that each thread will execute the whole test plan, which effectively utilizes the number of users that could use the tested service at any given time simultaneously.
• Ramp-Up Period R: Specifies how much time (in seconds) it will take for JMeter to start all the threads (simultaneous user connections). If the number of users is 5 and the ramp-up time is 10 seconds, then each thread will be started in a 2 second delayed interval. We need to be careful when setting this value, because if the value is too high the first thread will already finish processing the whole test plan before the second thread will even begin. This is important because that would effectively reduce the number of concurrent users using the testing server application at any given time. But the ramp-up period also needs to be high enough to avoid starting all of the thread at a single time, which could overload the target application.
• Loop Count (L): How many times each thread group will loop through all configured elements belonging to that thread group.
Hope it helps!

How does JMeter looping work?

Are the simulation loops separate? With separate I mean that JMeter waits for all threads to be done to begin a new iteration of the loop. Or does JMeter just let every thread do a request X time, without stopping?
Additional question: Could one change the number of threads dynamically? Doing a simulation for a range of number of thread (e.g. 100-1500) would be nice.
Each thread is completely independent. So when you have loop set, if a thread is finished its first loop of execution, it goes for another round (as per the loop count) irrespective of the completion of other threads.
You can use a variable for the number of threads & set the number via property files etc. But when the test is running, you can not change the no of threads for the test.
Hope it is clear!
In addition to vIns answer:
You CAN change load dynamically during execution. Threads count is static, but their fire rate is something you can impact.
Look into combination of Beanshell Server and Constant Throughput Timer.

JMeter: How to run test with rate of n concurrent requests per second

I would like to run the test with the given execution rate per second. The next iteration should start asynchronously at 2nd second without waiting for completion of first iteration.
I tried with Constant Throughput Timer but it doesn't proceed to next iteration until
it finish getting response of first iteration threads.
You can use 2 separate Thread Groups for this (make sure that you have Run Thread Groups Consecutively box unchecked at Test Plan level.
Also check your Constant Throughput Timer configuration Calculate Throughput based on field, you may wish to have separate timer for each Thread Group.
By the way, there is more advanced Throughput Shaping Timer element available via plugin which provides easy-readable graph demonstrating the load pattern.
If you will be considering using separate Thread Groups remember that JMeter Variables have scope local to the Thread Group where they are defined. To use them across different Thread Groups you'll need to cast them to JMeter Properties which have "global" scope. See How to Use Variables in Different Thread Groups guide for how to implement it.
A single thread can only handle one request at a time. You'll need more than one thread for what you're asking for. The constant throughput timer can indeed do what you're asking as long as you have enough threads.
In order to achieve what you're asking for (lets say 1 request every second, regardless of how long the request takes) you could I would suggest using a large number of threads and using the CTT for 60 requests per second.

Resources