How to make JMETER make 166 requests in 1 second? - java

I need to make stress testing for some service and I need to make 10 000 requests.
How to make correctly 166 requests in 1 second ?
Have I made correct settings below ? (picture below)

If you want to make 166 requests in 1 second and stop here is the relevant Thread Group setup:
If you want to make 166 requests per second for 1 minute resulting in 9960 requests it's better to consider using Throughput Shaping Timer configured like:
in that case it makes sense to use Concurrency Thread Group which can be connected to the Throughput Shaping Timer via Feedback Function so JMeter could kick off extra threads if the current amount is not enough to conduct the necessary number of requests per second

Add a new thread group.
Add 166 threads as thread count.
Add 1 sec as Rampup time.
Set looping condition as 1.
Then Implement the HTTP request and run the test

Related

How to implement scheduling inside a running thread group?

I am testing a certain "functionality" that happens after log in.
The test case is 500 users exercising that functionality within 5 minutes.
I can add a synchronising timer after the log in, to ensure all 500 threads have logged in but then it will do all 500 "functionality" tasks at once, rather than 5 minutes, which will crash the app (it thinks there's a DDoS attack and shuts down).
Right now, I am handling this by giving some think time after login, to slow down login to a stable figure that I can predict and then start "functionality" at each thread's turn, as scheduled by: the main scheduler + the the log in response time + the think time...
But that's a bit fuzzy.
Is there a way to "ramp up" tasks once already running?
I can think in two options.
The first one is two use random times. You would use the range from 0 seconds to 300 - 1 that is [0-300) or using millis [0-300000). Then sleep the thread basesd on this ramdon time.
This approach can be a little more realist, because for instance, in a specific second of the given interval you don't have any threads starting and in other particular second you have 2-3. This still should be well balanced in general, since you won't make all petitions at start.
The second one is to start the threads uniformly. During your configuration time (login and before firing the threads) you can use something like an AtomicInteger, initializing it with new AtomicInteger(0) and calling getAndIncrement() to assign the possition of the thread, in the range [0-500) and then when you fire the threads sleep 300.0 * id / 500.0 milliseconds to execute the task/petition.
By default JMeter executes requests as fast as it can, you can "throttle" the execution to desired throughput (request per minute) rate using Constant Throughput Timer.
Example Test Plan would look like:
Thread Group
Login
Synchronizing Timer
Functionality
Constant Throughput Timer
Constant Throughput Timer follows JMeter Scoping Rules so you can apply it either to single sampler or to a group of samplers.

Make a thread generate fixed number of requests per second

I am doing calculations in milliseconds and I really do not want my thread to spend more time doing time calculations rather the job it is assigned to do. However I want to implement something that:
1- It should not generate more than n requests per second
2- If it has generated less, it should start at zero for the next second(obviously :D)
I am trying to do some performance benchmarking where my goal is to give all cpu to only processing and not time computations after every request. Roughly, I am processing
08:36 - 171299
08:37 - 170970
08:38 - 163763
I want to make sure I do not make more than 160000 requests per minute here. How to acheive that is the problem.
Thanks in advance!
You can combine ScheduledExecutorService to run some code every second and this answer to set timeout on that code. In the end, your runnable that should have 1-second timeout should generate up to n requests, and if it times out, it will start in next second with new context.

Jmeter threadgroup sharing counter between threads

I want to create a Thread Group in jmeter to create users and their devices with many (for example 5000) devices.
I have no problem to create this test and I want to have the name of the users and device in a correlative order.
1. user1--device1
2. user2--device2
3. user3--device3
I already created the test but to create 5000 users and devices in the same Thread Group I need to run 5000 iterations with 3 requests each, using 1 thread, because otherwise I have the same user name repeated by multiple threads (for example with 3 threads)
1. user1--device1
2. user2--device2
3. user3--device3
4. user1--device1
5. user2--device2
6. user3--device3
7. user1--device1
8. user2--device2
9. user3--device3
My question is: is there any way to share the loop counter between threads in order to create 5000 users/devices with more than one thread (for example 20 threads).
This will help me a lot because instead of waiting for 20 minutes, it will be a minute to create the users.
Many thanks!
http://pastebin.com/S1izFC9r
Added explanation I want for example maximun 9 devices (counter_max) but I want to run it with 3 threads. I want the result be like that
thread1--user1-device1
thread2--user2--device2
thread3--user3--device3
thread1--user4--device4
thread2--user5--device5
thread3--user6--device6
thread1--user7--device7
thread2--user8--device8
thread3--user9--device9
I think you can implement it using __counter() function in "global" mode, like: ${__counter(FALSE,)}
__counter() function returns incremented value each time it's being called
in the "global" mode counter value is shared across threads
So you should be able to use as many threads as required and each thread will use the next counter value to create your users and devices with multiple threads.
See How to Use a Counter in a JMeter Test article for comprehensive information on using "counter" config element and function.

Run concurrent webservice requests using JMeter

I need to run a performance test on JMeter against a SOAP-based webservice. I have set up the Tests for this. What I want to do is make 5 requests one after another in 1 thread group with a delay of 1 second between the requests for a certain amount of time (ex. 2 hours ...) BUT I don't want to wait for the response of one request and then proceed to the next i.e. I want to fire 1 request, wait exact 1 second, fire the second, wait exact 1 second fire the next request etc. and then collect the results after the test has finished. This is a requirement.
My Questions:
1. Does JMeter have any option to accomplish this task?
2. If the answer to the 1st question is yes, how would I accomplish such a task?
3. If the answer to the 1st question is no, is there a substitute for JMeter that can handle such a task?
Thanks,
You can add a Timer element to your samplers. You can configure the Timer to be constant (1 sec) or even choose the wait time to be drawn from a Normal distribution. Find out more info here: http://2min2code.com/articles/jmeter_intro/constant_timer
For the moment there is no possibility to configure JMeter to send requests as you described.
However JMeter provides the option to limit JMeter's throughput to 1 request per second. See How to use JMeter's Throughput Constant Timer for details on how to get this done.

Jmeter - simulating more complex load scenarios?

Been experimenting with Jmeter, and I'd like to know the best way to accomplish:
20 users logging onto an application, over 20 minutes, and performing some actions for another 20 minutes, before logging off over a period of 20 minutes. I.e. have 200 users logging on, and then once ALL of them are logged on, begin 20 minute timer. Once 20 minutes are up, start to log the ones who logged on earliest off.
I realise this MAY or MAY NOT BE a realistic testing scenario, but i'd like to see if it's possible.
At the moment I have a test plan whereby a user logs on, performs some actions, and then logs off. I can't see how I can ramp up and ramp down.
There's an option in Test Plan "Run thread groups consecutively". Set it to checked.
Then add 3 thread groups to your test plan. I'd suggest using Thread Group for first (20 threads, loop count 1, ramp up time 1), Ultimate Thread Group (20 threads starting immediately and holding load for 20min) for second and Thread Group again for third (20 threads, loop count 1, ramp up time 1).
Place appropriate samplers inside each TG - first just logs in, second does actions, third logs off.
That's it. If you have any troubles - let me know.
You'll need several thread groups in JMeter starting off and running at different intervals, in that way you could ensure that the users who start first will end first.
Also see a related question on this.
You can have no of users=20, ramp up time=1200 sec (1 per min), difference of time between test start and test end time=20 min to achieve that.
I think I had a similar problem in the past
Here Want I've did:
First set your thread group to have 20 thread with a rampup period of 60 seconds
After the login put a "test action" (in the sampler menu)
target = current thread, with the action pause and 20 minutes (1 200 000 ms) or more if you want to be safe.
After this test action, put all your navigating request.
Once your navigation is done, put another "test action" with the same setting has the previous one
(target = current thread, with the action pause and 20 minutes (1 200 000 ms))
put the logouf request after the sampler.
This should cover you case.
Take note that the sampler just pause your thread so the first thread that start should be the first thread that end.
If you want to scale it to 200 you just need to change your thread group rampup period to 6 or 5 seconds.
hope it's help.

Categories