How to calculate the number of threads and loop count in jMeter - 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!

Related

How to configure Jmeter to achieve desired throughput

I have created a performance test script as below. I am running 4 Thread Groups in parallel (Even though there are 14 Thread Groups, only 4 are enabled and I am running only those enabled 4 Thread Groups). I have used default Thread Groups.
I have used Flow Control Action to simulate the user think time and set it as 3 seconds.
My requirement is to achieve Throughput as 6.6/seconds. What is the best way to achieve it? Also, does user think time creates any impact on Throughput?
As per JMeter Glossary:
Throughput is calculated as requests/unit of time. The time is calculated from the start of the first sample to the end of the last sample. This includes any intervals between samples, as it is supposed to represent the load on the server.
The formula is: Throughput = (number of requests) / (total time).
So basically throughput is the number of requests which JMeter was able to within test duration time frame. If you introduce artificial delay of 3 seconds - it will make the overall throughput lower
Other (and the main factor) is your application response time because JMeter waits for previous request to finish before executing new one so there could be 2 options:
The amount of threads in your Thread Groups is not sufficient to create the desired throughput. If this is the case - just add more threads (virtual users) in Thread Group(s)
The amount of threads in your Thread Groups is too high and you're getting higher throughput that you expect. If this is the case you can pause JMeter even more by adding Constant Throughput Timer and specifying the desired number of the requests per minute you want to have. If you need 6.6 requests per second it will mean 396 requests per minute
Also remember that JMeter itself must be able to send requests fast enough so make sure to follow JMeter Best Practices
My suggestion is to consider using the Arrivals Thread Group. This TG will allow you to configure the desire average throughput (ATP); the TG will instantiate the required threads needed to achieve the ATP goal.
As for the Think Time (TT), it should be a business requirement that emulates the pauses that users take when using the application in the real world.

Running a JMeter test with multiple users with the same number of transactions over different time period

in Visual Studio Load testing there is an option in the test mix to set a value for each specific test to be run by all the users assigned to that scenario a specific number of times. Therefore if you want to increase the load by increasing the number of times a transaction is executed in a test you can increase the user load or set the number of times a particular transaction is run. This facility also spaces out each time a transaction is run, so that the transaction is run throughtout the test.
With Jmeter if I want to achieve a similar affect I would need to change the value of the ConstantTimer (I think) for each new user load.
Example:
Test time 300 sec, Transaction count required = 20, Thread Count =1, Constantimer =15 secs
Test time 300 sec, Transaction count required = 20, Thread Count =5, Constantimer =75 secs
Is the ConstantTimer the correct timer to use (with a loop obviously) for this?
If you want to execute a specific number of requests per unit of time, i.e. 20 transactions in 300 seconds the most obvious choice is using Constant Throughput Timer
20 transactions in 300 seconds is 4 transactions per minute and given you configure the Constant Throughput Timer like this:
you will "tell" JMeter to pause its requests to 4 transactions per minute no matter how many threads you have.
A more flexible option is using Throughput Shaping Timer and Concurrency Thread Group combination, this way you will not be only able to pause threads to limit JMeter's throughput to the given number of requests per minute, but also kick off new threads if current amount is not sufficient to reach/maintain the target throughput.

Jmeter: How to set up the stepping thread group?

How to set up the stepping thread group? If my application gives average response time as 2sec for 100VU by using "ThreadGroup".
Actually, it depends of your performance test goals. Stepping Thread Group won't allow parameters smaller than 1 second. You have to deal with this limitation.
According to JMeter documentation:
Ramp-up needs to be long enough to avoid too large a work-load at the
start of a test, and short enough that the last threads start running
before the first ones finish (unless one wants that to happen).
Defining the ramp-up time is a very important step of your performance test. In your case, I recommend start with 1 thread per second using these parameters:
This group will start 100 threads;
First, wait for 0 seconds;
Then start 1 threads;
Next, add 1 threads every 1 seconds using ramp-up 0 seconds,
Then hold the load for 900 seconds.
You can choose to stop all threads at once then. It is up to you.
Why am I suggesting to run a test for almost 20 minutes? Because you are interested in the performance running with 100 threads and you want to maximize the number of samples with such load level. On the suggested setup, you'll have approximately 90% of your test time running with the ideal number of threads.
Once you have those numbers, you can experiment by starting more than 1 thread per second and decrease the overall ramp-up time. Always look at the resource usage (e.g. CPU utilization, memory available, etc.) to understand the system limits.

How to use the Constant Throughput Timer to specify a maximum of 4 concurrents users per second, during an hour

I need to create a load test in which there's a maximum of 4 concurrent users per second. Then I need to repeat this for an hour.
Is there any way to achieve this in JMeter?
I have tried using this configuration:
Number of Threads: 4
Ramp-up period: 1
Loop count: Forever
Duration:3600
And to make sure that this run exactly for an hour I have also used a Runtime Controller with the same "3600" runtime value.
But these creates more concurrent users per second than what I need and besides it's also unlikely to have that many concurrent users as user usually take so time to think before they do something and this wasn't reflected in my configuration so also tried using Constant Throughput timer , but this only confused me more.
I'm sure I need to use the Constant Throughput Timer, but I don't have the faintest idea of how to do it in my case.
If a use the Constant Throughput Timer, how should I configure the Thread Properties (Number of threads, ramp-up period,loop count, schedule) ?
Do I really need to use a Runtime Controller, to ensure that the test plan runs exactly for an hour or is enough to specify a duration value of 3600?
Constant throughput timer allows you maintain throughput of your sever. (req/sec)
here requests are samplers. Threads are users/clients which are requesting server using samplers.
I hope this have cleared distinction between request and user i.e. sampler and thread.
Now Constant Throughput Timer works on sampler per minute basis. so for your requirement of 4 req per sec. it becomes 240 requests per minute.
and you want to maintain this throughput among all threads (if you have multiple thread groups) or among a single thread group if you have single thread group.
So JMeter engine will start all threads with given ramp-up but will allow only 4 samplers to executes at a given seconds i.e. only 4 request per second.
Thus throughput is achieved among all threads and you can continue this for a specified time using either ways,
Test duration
Runtime controller
I hope it cleared your confusion and solved the issue.

How can I interpret a Test Plan in which I have set a "Ramp-up Period" greater than zero

This is the first time I had to perform tests and I'm kind of confused about how to interpret the results I got when setting "Ramp-up Period" greater than zero.
To start, when I set a value of zero, if I'm not mistaken, this means that all the threads are launched at the same time. Therefore, one can conclude that the max number of threads that your application can successfully accept is equivalent to the max number of concurrent requests the tested application can accept.
Now that problem comes when I have to do some tests using a "Ramp-up Period" greater that zero, as I'm not sure what conclusions can I come to, or rather I don't know whether they are correct.
Based on what the documentation says:
Start with Ramp-up = number of threads and adjust up or down as
needed.
This is more or less what I've written:
1) To start our test we set that each thread will start 1 (15/15) second after the previous thread was begun. To do this we set the same value for both “Number of threads” and “Ramp-up Period”.
As the 15 requests are done successfully we start adjusting down the value for "Ramp-up Period", until we find the minimum interval of time that must exist between each request
2) Ramp-up Period = 13
3) Ramp-up Period = 10
4) Ramp-up Period = 7
5) Ramp-up Period = 6
So far all the requests were performed successfully, but with a "Ramp-up Period" of 6 only three requests had a response.
With this result we can conclude that the minimum time that must elapse between each call to the web service must be greater or equal to 0.46 seconds
This value is calculated by dividing the value of "Number of threads" and "Ramp-up (7 / 15)
What do you think about my conclusion? Is it right? What else one can conclude using jmeter in the way I showed.
As always your comments suggestions would be greatly appreciated.
Thanks
Ramp up is nothing more than virtual users arrival rate. JMeter starts from 1 thread and adds more threads as per ramp-up specified. 15 threads and 15 seconds ramp-up means that each 1 second 1 thread is being added. In case of 7 seconds ramp-up and 15 threads each second 2 threads are added. When thread doesn't have any work to do it's being shut down so make sure that you have enough loops in the parent Thread Group or Loop Controller.
There are at least 3 options of defining load scenario:
Ultimate Thread Group (free 3rd-party plugin) - provides convenient way of setting ramp-up, ramp-down and hold the load times.
Constant Throughput Timer - provides capability to set the load in "requests per minute"
Synchronizing Timer - provides the way of pausing requests until specified thread number is reached and firing them off at the same moment creating simultaneous concurrent requests.
Also:
Please don't use JMeter GUI for anything apart from tests development and debugging
Avoid View Results in Table Listener
The same for View Results Tree listener.
Follow other advices from JMeter Performance and Tuning Tips guide.

Resources