1
votes

I have a workflow that involves saving some data, and then updating it a few seconds later. I've created a CSV file with parameters like so:

ID,Success
1,true
2,false
3,true
4,false
5,true

And so on and so forth. The first HTTP request is to save a new ID:

POST http://server/save
{ id: 1 }

And the second HTTP request updates the ID with the status:

POST http://server/update/
{ id: 1, success: true }

I've created a JMeter test to benchmark this workflow. I created a Thread Group with the following steps:

1. Do save request
2. Wait a random period between 5 and 30 seconds
3. Do update request

I've set my Thread Group to use 2 threads at once as an initial test. However, I've noticed that what happens is actually this:

Thread 1
----------------------------------------------------
| 1. Do save request                               |
| 2. Wait a random period between 5 and 30 seconds |
| 3. Do an update request                          |
|--------------------------------------------------|

Thread 2
----------------------------------------------------
| 1. Do save request                               |
| 2. Wait a random period between 5 and 30 seconds |
| 3. Do an update request                          |
|--------------------------------------------------|

Problem is, what I'd actually like to do is ensure that there's always 2 simultaneous HTTP requests to the server. In this case, it spawns 2 threads and runs through the ENTIRE workflow as one thread, meaning that I can't guarantee a certain load on the server. What I'd like for it to do instead is this:

Thread 1
-------------------------------------------------------
|                                                     |
|  HTTP request                                       |
|  **********************************************     |
|  * 1. Do save request                         *     |
|  **********************************************     |
|                                                     |
|    2. Wait a random period between 5 and 30 seconds |
|                                                     |
|  HTTP request                                       |
|  **********************************************     |
|  * 3. Do update request                       *     |
|  **********************************************     |
|                                                     |
|-----------------------------------------------------|

Is there a way that I can write my JMeter test such that it will ensure that there are always 2 simultaneous HTTP requests on the server? Also, the update request must happen after the save request, otherwise the ID will not exist.

Here's an image of my JMeter test:

The while controller simply processes every line in the CSV file.

2
Why do yo want to use one thread sending quiet random requests instead of two threads sending requests in a sequence?Andrei Botalov
Because I need to simulate a workflow where the user saves some data, confirms it on his page, and then sends the success status. Think shopping cart, for example. User first creates a shopping cart, confirms on his screen that the cart looks correct, and then places the order.Daniel T.
Any news on that ? Was my answer helpful ? If yes you should accept it, if not you can commentUBIK LOAD PACK
Hi PMD, I've found another solution using JMeter Plugins, available here: code.google.com/p/jmeter-plugins. It provides a Throughput Shaping Timer which does exactly what I need (limit the number of requests per second to the server).Daniel T.

2 Answers

1
votes

I am sorry to say I don't understand you question. What do you want to achieve exactly, particularly in your last workflow description.

Anyway if you notice that you don't have simultaneous requests with 2 threads that can be totally regular as you have high pause time and only 2 threads.

Try with 100 threads you will see you have simultaneous requests.

Some notes about your test plan:

  • You don't need while controller to iterate over CSV, just set iteration in thread group to infinite

  • remove View Tree Results and Response Time Graph when you load test

0
votes

lower the 'ramp up' period for threads in the Thread Group (give it 0 seconds). that means they will both start up simultaneously.