In my application I want hit 20000 request in 10 hrs but I want distribute load in different time with different number of request means ex in 1 hrs 2000 request second hrs 3000 request third 1000 request like that how achieve this means how to separate load in diff time with diff no. of request
The easiest option is going for Throughput Shaping Timer, configuration implementing your described setup:
It's a good idea to use Concurrency Thread Group in combination with the Throughput Shaping Timer, they can be connected via Feedback Function so JMeter would be able to start extra threads if the current amount is not sufficient in order to reach/maintain the desired number of requests per second.
Both are JMeter Plugins and can be installed using JMeter Plugins Manager
Another solution could be using Constant Throughput Timer.
N.B. although the Timer is called the Constant Throughput timer, the throughput value does not need to be constant. It can be defined in terms of a variable or function call, and the value can be changed during a test. The value can be changed in various ways:
You could set the throughput using a property or variable.
Calculate the throughput values you need at different time intervals and set the property when the time is reached.
props.put("currentTPM", 120)
You will have some work in checking the duration since the test is started.
You may create a separate thread group to control the throughput. Rename the thread group name to TG-TM. Set the number of threads to 1 and loop count to infinite. Set the duration of the thread group.
def lstThrouputInOneHour= [2000,3000,1000,5000,4000,5000]
def currentIndex=vars.get("__jm__TG-TM__idx").toInteger()
if (currentIndex <lstThrouputInOneHour.size() ) {
def currentTPH=lstThrouputInOneHour[currentIndex]
def currentTPM=currentTPH.intdiv(60)
props.put("currentTPM",currentTPM.toString())
Thread.sleep(60*60*1000)
}
Note: Please introduce a startup delay to other thread groups to ensure they have access to the throughput value when they start.
This solution can be extended to work with Bean Shell Server where you could change the throughput values (JMeter properties) remotely
Related
In Jmeter, I am using Concurrency Thread Group with ${__tstFeedback(ThroughputShapingTimer,1,10,10)} in combination with the Throughput Shaping Timer to dynamically change the target throughput throughout the test duration.
I want to have a JSR223 test element (Assertion or PostProcessor, does it matter?) in which to write custom logic to not log some specific error but only if it occurs near the end of the test script and I don't want to hardcode the time value.
For example if I get a java.net.SocketException in the last 2 minutes of the scheduled run time, I want to not log it, but I do want to log it in the rest of the time.
For this, I suppose that I need some way to grab the date when the test is supposed to end since the beginning of the test, evaluate it and subtract 2 minutes from it and then compare the current time with that time and then if the current time is higher, then start doing some logic to exclude the result from the logging.
Update: In the "Normal" or "Default" Thread Group I noticed that I can do this to get the initial duration:
String groupDuration = ctx.getThreadGroup().getDuration();
log.info(groupDuration)
But for the Concurrency Thread Group it does not work the same.
I would appreciate any information to help me achieve this goal.
If your Concurrency Thread Group is configured with a Throughput Shaping Timer and Schedule Feedback Function the scheduled test duration is available through a property exposed by the Throughput Shaping Timer.
props.get('elementName_totalDuration')
The element will export the following propertyy that you can access through __P function or using in JSR223 Test Elements props.get("property name")
elementName_totalDuration - Total duration as sum of the
"Duration,sec" column
elementName will be the name of your Throughput Shaping Timer
NOTE
You should set Hold Target Rate Time to a value equal or greater than the total Duration specified in the Throughput Shaping Timer schedule. Hence set this value to a very high value to avoid test completing before scheduled duration in Throughput Shaping Timer. e.g Set Target Hold rate t0 1440 minutes.
Using concurrency Thread Group with Throughput Shaping Timer and the Feedback Function
When this thread group is used with Throughput Shaping Timer, you may replace Target Concurrency value with a call to the tstFeedback function to dynamically maintain thread count required to achieve target RPS. When using this approach, leave Concurrency Thread Group Ramp Up Time and Ramp-Up Steps Count fields blank, but be sure to set Hold Target Rate Time to a value equal or greater than the total Duration specified in the Throughput Shaping Timer schedule.
For dynamic thread groups and derivatives you can use the following function:
ctx.getThreadGroup().getHold()
If you need to determine whether it is in minutes or seconds you can use
ctx.getThreadGroup().getUnitStr()
Example:
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
You can filter results after test with Filter Results Tool
If you want to remove the ramp-up phase, you could use offset filters
Using --end-offset 120 parameter (seconds)
For the given scenario in sample scenarios image with duration 1hr , i tried to set the work load model as given below with the request hits 40000 and TPM 667:
Test Plan
thread group
Loop controller
Constant throughput timer
JSR223sampler1 (sleep time 3000ms)
JSR223sampler2 (sleep time 3000ms)
JSR223sampler3 (sleep time 3000ms)
JSR223sampler4 (sleep time 3000ms)
summary report.
Since I am new to the Jmeter i am not able to set the values properly... Can anyone help me?
Thread Group needs to be set up as:
Loop Controller should be allowed to iterate infinitely:
Constant Throughput Timer should be applied to all active threads in the current Thread Group and the Target Throughput should be 667.0
The above setup should fulfil the requirements for your scenario. Also be aware that sometimes the defined number of virtual users might be not enough to reach/maintain the desired throughput, in such cases it makes sense to consider using Concurrency Thread Group and Throughput Shaping Timer combination.
I am trying to configure a test for signup-login with invalid credentials imitating bruttforce attack. However, I want to make requests as a single user.
So the scenario is the next:
Request to sign up with valid params;
Attempt to log in with invalid params in a loop.
I am adding throughput timer but then I need to set up a high number of threads to generate for example 1 request per second.
How can I set exactly one user and run only one request per second in a loop?
UPDATE - SOLUTION
Everything was rather simple but still strange for me.
Maybe someone will face the same problem.
To get a number of requests per one user throughput timer should be placed not inside the controller but inside the thread itself.
To achieve Target Request Per Second use Throughout Shaping Timer : How to use Throughput Shaping Timer
JMeter Plugin link : Download from here
Few Important Notes:
JMeter threads of Thread Groups in scope of the Element will be
stopped when RPS schedule finishes.
Provide enough working threads for your RPS, JMeter timers can only delay threads (and limit RPS). You may pair this plugin with Concurrency Thread Group using Schedule Feedback Function to dynamically maintain thread count required to achieve target RPS.
If you're using versions of JMeter lower than 3.3 and if you have RPS that lower at the end of test, make threads to lower also. Оtherwise you'll have a spike in last second.
Avoid using zero RPS value as start of test, this produce spike also
Avoid zero RPS during the test, this may lead to nasty effects
Now, practical example showing 1 RPS for 1 User:
You might want to reconsider the location of the timer, it obeys JMeter Scoping Rules so it gets applied to all Samplers which are in your Thread Group.
If you want to apply it to only one - make it a child of the relevant sampler.
Also be aware that Constant Throughput Timer is precise enough on minute level so you might want to switch to the Precise Throughput Timer
I am quite new to jmeter and try to do a performance test of my application. I want to generate 100 request per second scenario however my server takes 3-4 secs to respond to every request. I am running my test for 1 mins which means number of requests fired should be 60k within the time span. However jmeter actually waits for the response before it sends next request. Which is not what I am looking for.
How can I make sure that jmeter sends a new requests every second with 100 req/sec without waiting for the response so that the number of requests fired per min is 60k.
I am trying to use constant throughput timer with 60k as request per min, however that is not helping. Here is my test screenshot.
EDIT
I have done like this
And Throughput shaping timer being as
So ideally I should get number of samples as 3000?, still not getting that.
Make sure you provide enough threads (virtual users) under Thread Group, "vanilla" JMeter won't kick off any extra threads if actual throughput is less than target one you specify in the Constant Throughput Timer.
Another solution would be using Concurrency Thread Group along with the Throughput Shaping Timer. They can be tied together via feedback loop so if you use these test elements JMeter will start more threads if the current amount won't be enough to reach the desired requests per second rate.
You can install both using JMeter Plugins Manager
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.
I would like to execute a loop of HTTP requests with an incrementally number of users.
For example, I want something like that :
1st loop : 1 user
2nd loop : 2 users
3rd loop : 3 users
...
Is that possible with the JMeter GUI ?
Thanks in advance !
You can achieve this effect by using the Stepping thread group plugin
You can gradually increase the number of concurrent users in JMeter. But not in the way you are actually asking ie, every loop / iteration!
Simply - You can not change the thread count within the test once the JMeter test has started running . But you can use variables for the user count and supply to the test before the test starts.
To gradually increase the user count, you can use any of the below thread groups
You can use the regular thread group, ramp-up period. 100 users and 1000 seconds ramp up period, will add 1 user every 10 seconds.
Stepping Thread Group
Ultimate Thread Group
Actually JMeter doesn't allow this, however you can work it around using different approach, for instance if you stick to Requests Per Minute rather than to Virtual Users.
You can use Constant Throughput Timer to set desired initial throughput (i.e. N requests per minute) and increment it by desired factor each Thread Group iteration.
Despite word "Constant" in its name the throughput doesn't have to be constant, it can be a JMeter Variable or Function or JMeter Property.
Reference material:
How to use JMeter's Throughput Constant Timer
Beanshell Server
Throughput Shaping Timer - an advanced version available via JMeter Plugins, has some extra scheduling capabilities.