How to control no. of requests per user in Jmeter - jmeter

I am doing load testing for one ecommerce website. I am using Ultimate thread group.
Now I want to send per user only 1 request. So for ex: If 500 users then only 500 request should send. How can I achieve it using Ultimate thread group?
Why I want above because I am doing whole process like login, select product, add to cart and checkout. So it should do everything only once per user.

Your test design is a little bit flaky as given each user does login, select product, add to cart and checkout you will have at least 4 requests per user which gives 2000 requests in total (doesn't include embedded resources calls). You can use Transaction Controller to group these requests into one "workflow" however it won't limit actual amount of requests.
If you need to run your workflow by each user only once you may run into a situation when either load will be less than 500 concurrent users or test duration will be less than 30/60 minutes, see JMeter Test Results: Why the Actual Users Number is Lower than Expected
If you add more iterations each user will be executing your workflow more than once
Normally web test plan should look as follows:
Given each user executes test scenario steps and acting like a real user
Gradually increase the number of users unless application response time becomes too high or errors start occurring, whatever comes the first
Analyze results, identify the bottleneck, report your findings

Lets say the duration of the test is 1 hour. First user completes the workflow you had mentioned in the first 10 mins itself. What should happen after the workflow for the user? Should the thread be idle for the remaining 50 mins?
I think you should use the regular Thread Group with 500 threads and loop count as 1. Ultimate Thread Group is for duration based tests. You could use Once Only Controller as a workaround inside to do the action only once for the user. But it is an ugly approach.

You can use Throughput Controller.
The Throughput Controller allows the user to control how often it is executed. There are two modes:
percent execution
total executions
Percent executions
causes the controller to execute a certain percentage of the iterations through the test plan.
Total executions
causes the controller to stop executing after a certain number of executions have occurred.
Like the Once Only Controller, this setting is reset when a parent Loop Controller restarts.

Related

Jmeter Scenario: Users Login once - pause until all logged in and execute process (based on iterations not time) - processes complete users log out

I'm relatively new to Jmeter but I have a scenario that I've not been able to figure out where I need to perform the following:
All user log in to application with a ramp-up period of 15 seconds between users.
No activity continues until all users log in to application.
Once all users are logged in, perform their set of business activities (will vary depending on business process, and based on iterations, not a time loop).
Once all users are complete business processes, users begin to logout with ramp-down time of 15 seconds between users.
Is this possible to configure my script to execute this way and if so, how? I have tried use of Once only controllers, loop controllers, constant timers, and some various plugins (Custom Thread Groups). I've also viewed various threads and not been able to find this exact scenario, but cannot imagine this is an overly unique test case...
Any recommendations or advice is appreciated.
Thanks!
This is highlighted in question above
Ramp-up period can be easily configured using "normal" Thread Group
To "wait" until all the users are logged in use Synchronizing Timer
Use Loop Controller to run the "business activities" as many times a you want
The same to wait until all the users finish executing their "business activities"
To implement ramp-down you can use JSR223 Timer and the following code:
return (ctx.getThreadNum() + 1) * 15000
where ctx stands for JMeterContext, see JavaDoc for all available functions and Top 8 JMeter Java Classes You Should Be Using with Groovy for more information on this and other JMeter API shorthands available for the JSR223 Test Elements.

jmeter - I would like to know if it's possible to have login as part of the set up and logout as part of tear down for 250 concurrent users

I have scenario where I want to run load test for 250 users.
Ramp up time is 10 mins for 250 users and run test for 50 min duration.
Question 1 : Is it recommended to do login and login out as part of set and tear down .. as the dev team does not measure login and log out .?
Question 2 : How do i keep the the other thread group in loops during the 50 min duration . ?
I wouldn't go for it as normally different thread groups should represent the different groups of virtual users, setUp thread group is for accomplishing the pre-conditions for the test and tearDown thread group is for cleaning everything up. If you perform the login in the setup thread group - there will be negative consequences like having to pass login context (tokens, headers, cache, etc.) to other thread groups. So I would rather move login to be the integral part of the main thread group and if needed remove login/logout via Filter Results Tool (not part of vanilla JMeter, can be installed using JMeter Plugins Manager)
It can be done on either on Thread Group level like this:
or you can "loop" the arbitrary part of the test by putting it under the Runtime Controller:

How to Baseline a Web application using Jmeter

I want to Baseline my application .It is having two transactions "Place Order" and "Add A Product To Favorites".. Both of these transactions follow the same navigation route mostly. For the - Place Order Business Transaction the steps are Land on Login Page .. Login..Add To Cart..Checkout..Place Order. For the - Add A Product to favorites Business Transaction, the steps are : Land on Login page..Login....Add To Cart...Add to favorites. I want to run Test and see the consistent response time the application gives at a particular throughput. I have the below queries.
If I create Add to Favorites scenario as a Thread Group with 4 samplers and Place Order Scenario with 5 samplers(as given by the steps mentioned ), should I add a throughput Shaping Timer separately for the individual Thread Group and if so what would be the Throughput parameters that I should give like RPS settings.
My application has the following Max response time and avg response time for a normal Load(i.e with no queue wait time since I collected the response times by just running a single thread so that the Wait time component is Zero) .N.B L I have not added the think time for simplicity sake and also the response times are bit too costly since the backend ERPs are legacy systems.
So, the Thread Group that I will create for "Place Order" has http samplers below with their respective response times for a 1 user load:
Land on Login page - 6074 ms (avg 4492 ms)
Login using Credentials - 2549 ms (avg is 631 ms)
Add To Cart - 1553 ms (avg is 304 ms)
Land on Cart page: 47044 ms (Avg: 15901 ms)
Place Order : 19126 ms (avg is 17110 ms)
Logout : 4801 ms (avg is 2706 ms)
Below are my queries:
With the above response timings what is the max throughput i.e Place Order transactions that I can achieve so that I can set that as the TPS parameter in the Throughput shaping graph plugin and then run a load test. Please can somebody explain the calculation process to arrive at that value.
The same samplers (i.e Land on Login Page and Login and add to cart ) is used in multiple Thread Groups like the Place order Business Scenario above and the Add A Product To Favorite Business transaction . So my question is, if different Thread groups are going to pound the same Login Controller Servlet/Add to Cart Servlet (my app is a J2EE app) so how to take that into consideration so that the queue generated for the Login sampler will not affect the TPS to be achieved by place order Business scenario and the other Business scenarios that use the login sampler transaction since we will be running both the Thread groups.(One for Place Order and One thread Group for Add to favorites) while running the Load test
How to set the concurrency for a Thread group; say the Place Order Transaction .I have this question since we need to know the max response time. Hence should I add the entire response times of all the samplers in the Thread group and multiply by the TPS that we calculated and divide by 1000 .Please explain the logic in this case too.
Nobody apart from you can answer, from your numbers we can state that 1 user is capable of executing 1 Place Order request in 19 seconds or 3 Place Order requests per minute. If you add one more user there could be 2 cases:
Response time remains the same. In this case you will be able to execute 6 requests per minute with 2 users, 9 requests per minute with 3 users, etc.
Respons time increases. In this case you will NOT be able to execute 6 request per minute with 2 users due to performance bottleneck.
Check out What is the Relationship Between Users and Hits Per Second? article for more details.
I don't think you should be measuring various business use cases separately, well-behaved load test should represent real-live application usage as close as possible and in reality it is more than possible than one user creates and order while other users are logging in. However if you explicitly need to test order creation separately you can perform login in setUp Thread Group and then pass the authentication context (in majority of cases it is a set of Cookies) to the main Thread Group where the order creation takes place using i.e. Inter-Thread Communication Plugin
You don't need to know response time, you need to provide enough virtual users in order to conduct the required load (given the application is capable of handling it), consider using Concurrency Thread Group which can kick off extra threads if the current amount is not enough for maintaining the desired throughput. It can be connected with the Throughput Shaping Timer via Feedback function.

Jmeter - Variation in count of different http requests within same thread group

Requirement: Load for a total of 100 users within an hour. Each user hits 3 different services different number of times at the same time.
for example: user 1 is going to hit service1- 3 times, service2- 5 times and service3 - 4 times at the same time. Same will be repeated for 100 users over 1 hour.
I have a thread with users-100, rampup time -60 (min). and then I am using parallel plugin and within that plugin created those 3 different sample requests. But I don't know how to configure the number of times, each of those service will be called per user at the same time.
Your test scenario doesn't make sense, normally 1 thread (virtual user) can hit only one endpoint at a time. The use when user executes 3 same requests to the same endpoint looks very suspicious as well. So I would recommend reconsidering your scenario and implement distribution using one of the following approaches:
Use different Thread Groups for different requests
Use Throughput Controller
Use Switch Controller
Use Weighted Switch Controller
If however I'm wrong and you're trying to implement some form of AJAX testing when requests are being triggered at the same time and in parallel - example test plan would be something like:

How do I load test sequential APIs one by one using Jmeter

I'm using Jmeter to load test an application.
No: of threads is 100.
First HTTP request is the home page.
Second HTTP request is login page where the actual login is made
.
.
n APIs are there.
and what I want to achieve is:
First 100 threads hit the home page concurrently.
Then 100 threads hit the login page concurrently.
.
.
Then 100 threads hit the nth API concurrently.
Add Synchronizing Timer as a child of each request which you need to execute "concurrently"
Set Number of Simultaneous Users to Group by to be equal to the number of concurrent users, in your case 100
Reference: Using the JMeter Synchronizing Timer
Although above approach answers your question better scenario would be starting with 1 virtual user and gradually increase the load, in this case you will be able to correlate increasing load with performance metrics like Response Time, Transactions Per Second, resources consumption of the application under test, etc. as the situation when 100 users open login page and then hit "Login" button at exactly the same moment is highly unlikely to happen and well-behaved load test needs to represent real usage of the application by real users as close as possible.
Threads number 100 ,You need to put each request with synchronizing timer under 3 controllers, See tutorial

Resources