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.
Related
Currently I have a camel route that makes a few API rest calls and puts the results in a database, and does this serially:
Enter route
Setup task
Call/insert 1
Call/insert 2
Call/insert 3
Finalizing task
I would like to make these calls happen in parallel.
Enter route
Setup task
Make external calls in parallel manner:
Call/insert 1
Call/insert 2
Call/insert 3
Finalizing task
Each step in the serial mode is currently its own camel route, so things are already fairly modular. My two main questions are:
best way to call the call/insert routes in a parallel manner?
I have seen examples that split up the body and send each part to a different thread, but that's not what I need here.
I have also seen setting up using .multicast().parallelProcessing().to("direct:id1", "direct:id2");; Is it as easy as that? Can I just specify the separates routes to parallelize? Is this best practice? Anything to know or note about this?
How to wait for all the threads to finish? Error handling?
Currently each external call route goes to the next. Where should they go when they are made parallel? Can I just not specify the next step?
How to handle potential errors that occur in one or more of the threads? How can I make sure these are handled? Currently each step error-checks and goes to a generic error-handler
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
I am doing API load testing with JMeter. I have a Macbook Air (client) connected with ethernet to a machine being tested with the load (server).
I wanted to do a simple test. Hit the server with 5 requests per second (RPS). I create a concurrency thread group with 60 threads, a throughput shaping timer with 5 RPS for one minute, my HTTP request and hit the play button and run the test.
I expect to see my Hits per Second listener indicating a flat line of 5 hits per second, instead I see a variable rate, starting with 5 and then dropping to 2 and then later to 4... Sometimes there is more than the specified 5 RPS (e.g. 6 RPS) the point is that it's not a constant 5. It's too much of a variable rate - it's all over the place. And I don't get any errors.
My server, takes between 500ms to 3s to return an answer based on how much load is present - this is what I am testing. What I want to achieve with this test is to return as much as possible a response in 500ms time under load and I am not getting that. I have to start wondering if it's JMeter's fault in some way, but that's a topic for another day.
When I replace my HTTP sample request with a dummy sampler, I get the RPS I desire.
I thought I had a problem with JMeter resources, so I change heap size/memory to 1GB, use the -XX:+ DisableExplicitGC and -d64 flag and run in CLI mode. I never got any errors, not before setting the flags and not after. Also, I believe that 5 RPS is a small number so I don't expect resources to be a problem.
Something worth noting is that sometimes, the threads start executing towards the end of the test rather than at the start, I find this very odd behaviour.
What's next? Time to move to a new tool?
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.
I have a JMeter test plan with following http request samplers.
Login
Call some functionality which needs a logged in user
Logout
When I execute the test plan with 5 parallel threads, I see that the sampler 2 is called before calling sampler 1 for some threads, which then fails the response assertions.
Is there any way to specify a sequence of samplers to be executed ?
This should ensure that they are executed sequentially :
So let's start with thread group.
Number of Threads(users) is 5.
So assuming you have the logic work out for your login sampler. Just add additional sampler to it. So right click on that sample Add > Post Processors > BSF PostProcessor, inside this post processor big script space write ${__setProperty(ThreadValue,${__threadNum},)}.
This will save the thread number to your property called ThreadValue. Make sure you select your language as beanshell in the dropdown list.
Then after the login sampler add the if controller. Add this to the condition field (${JMeterThread.last_sample_ok}==true) && (${__property(ThreadValue,,)} == ${__threadNum})
What this means is that -> do only logged in stuff while the actual login is successful and if the login thread matches the thread you're currently in.
That's it you do your login stuff only inside the if controller. If you want to be sure that you logout the right user place additional if controller arround it.
Cheers
What you need to consider is that each thread is a separate entity, like a real user, and that it has it's own session, but that JMeter is designed to execute these threads asynchronously, ie. in parallel. The View Results Tree listener displays all activity, from all threads as it happens regardless of the logical thread sequence. If you would rather have 1 thread make 5 iterations then simply change the thread count to 1 and use a loop of 5 and this will preserve the sequence (although this defeats the point of using a load testing tool like JMeter!).
If you do change the thread count to 1 then you can see the true, logical sequence of execution in the results tree. This will show each sampler being executed, in sequence, top down.
Now, in your case, I suspect you have a problem not because things are being run out of sequence but rather because the server is losing the session context between requests. This is very common and more often than not you can address the problem using a HTTP Cookie Manager or with the use of a Regular Expression Extractor.