Mega
Mega

Reputation: 1

Jmeter:- How to Send multiple request concurrently/Sequentially in "Jmeter" with different set of values for each request?

For example, below is the JSON request data to "add a device" in the DB. For example, I want to add 10000 devices with different IMEI number and different phone number to the server for testing purpose. So, how to send the request at once. I'm ready to create 10000 devices data with different values manually. Now I can able to send one by one only.But how to send all the request at once?

{ "device_name":"34793812453274392", "imei_num":"36xxxxxxxxxxxx5", "phone_num":"8666606451", "device_city":"Chennai", "device_state":"Tamil Nadu", }

As I'm new to Jmeter, required detailed info. Thanks in advance.

Upvotes: 6

Views: 28690

Answers (4)

Ritesh Singh
Ritesh Singh

Reputation: 223

  1. first create a thread pool under your plan and add Sampler -> HTTP Request (Right-click on TestPlan and create a thread group. Again Right click on thread group to create sampler)
  2. Configure your HTTP request with your post method data and API.
  3. Repeat step 1 and 2 with different data
  4. finally create a listener for your plan and Run

Note: Unselect Run Thread Groups Consecutively (i.e one at a time).Below is a screenshot for overall architecture: Each thread group have one post method with a different body

Here is a screenshot for overall architecture: Each thread group have one post method with a different body

There is also a different way in which you can pass your inputs via CSV file. You can check that out here: https://www.blazemeter.com/blog/jmeter-parameterization-the-complete-guide

Upvotes: 4

Imran
Imran

Reputation: 181

You should add multiple "Thread Group" into a "Test Plan". Inside "Test Plan" Unselect "Run thread groups consecutively".

Inside every "Thread Group" configure "Number of Threads(users)" as "1", "Ramp-Up Period" as "0", "Loop Count" as "1".

Now, add "HTTP Request" into each "Thread Group". Every "HTTP Request" you can add your "JSON file" and configure the "URL". Configure all the "HTTP Request" according to this.

Now add "View Results Tree" as a listener into a "Test Plan". Now run the Test plan.

Upvotes: 10

Dmitri T
Dmitri T

Reputation: 168072

  1. You can use __Random() function to generate different phone_num and imei_num values like:

    {
        "device_name": "34793812453274392",
        "imei_num": "${__Random(111111111111111,999999999999999,)}",
        "phone_num": "${__Random(8666606451,9999999999,)}",
        "device_city": "Chennai",
        "device_state": "Tamil Nadu",
    
    }
    
  2. In order to configure JMeter to send all 10 000 requests at exactly the same moment:

    • Configure Thread Group to have not less than 10 000 threads (virtual users)
    • Add Synchronizing Timer as a child of the request which adds the device to the database and set Number of Simultaneous Users to Group by to 10000

Be aware that 10 000 is quite high number of virtual users so make sure you're following JMeter Best Practices in your script.

Upvotes: 1

Jerome L
Jerome L

Reputation: 637

However, JMeter is able to simulate multiple concurrent users using Thread Groups. You can then combine a CSV Dataset config with your Http Request Sampler like explained in Multiple Login with JMeter.

The CSV should contain the IMEI numbers. Each concurrent thread group will pick a different value from the CSV value and send it within the HTTP Sampler.

Remember Http Requests within a Thread Group can only be played sequentially.

Upvotes: 1

Related Questions