How to use Constant Timer in JMeter

Last Updated On

HOME

In this tutorial, we will discuss the Constant Timer in JMeter and its use in Load Testing.

Table of Contents

The sample request and response used in this tutorial is shown below:

Sample Request

{
    "name": "JMeter",
    "job": "Testing"
}

Sample Response

{
  "name":"JMeter",
  "job":"Testing",
  "id":"809",
  "createdAt":"2023-07-27T18:46:18.038Z"
}

Create a Test Plan in JMeter


Step 1 –  Add Thread Group

  • Select Test Plan on the tree
  • Add Thread Group                                                                                                                               To add Thread Group: Right-click on the “Test Plan” and add a new thread group: Add -> Threads (Users) -> Thread Group

In the Thread Group control panel, enter Thread Properties as follows: We will take an example of row no 5

Number of Threads: 1 – Number of users connects to the target website
Loop Count: 10  – Number of times to execute testing
Ramp-Up Period: 1 – It tells JMeter how long to delay before starting the next user. For example, if we have 5 users and a 5 -second Ramp-Up period, then the delay between starting users would be 1 second (5 seconds /5 users).

Step 2 –  Add HTTP Request Sampler 

The JMeter element used here is HTTP Request Sampler. In HTTP Request Control Panel, the Path field indicates which URL request you want to send


Add HTTP Request Sampler
To add: Right-click on Thread Group and select: Add -> Sampler -> HTTP Request

The below-mentioned are the values used in HTTP Request to perform the test

  • Name – HTTP POST Request Demo
  • Server Name or IP – reqres.in
  • Protocol – https
  • Method – POST
  • Path – /api/users

Step 3 – Add HTTP Head Manager

The Header Manager lets you add or override HTTP request headers like can add Accept-Encoding, Accept, Cache-Control

To add: Right-click on Thread Group and select: Add -> Config Element -> HTTP Read Manager

The below-mentioned are the values used in Http Request to perform the test
Content-type = application/json

Below is the image once HTTP Header Manager is added to the Test Plan.

Step 4 – Add a Constant Timer

Step 6 – Adding Listeners to Test Plan

Listeners – They show the results of the test execution. They can show results in a different format such as a tree, table, graph, or log file
We are adding the View Result in Table

View Result in Table – The View Result in Table listener displays information about each sample in the form of a table. 
To add: Right-click on Test Plan, Add -> Listener -> View Result in Table

Note – Don’t use “View Results Tree” or “View Results in Table” listeners during the load test, use them only during the scripting phase to debug your scripts.

Step 7 – Save the Test Plan

To Save: Click File Select -> Save Test Plan as ->Give the name of the Test Plan. It will be saved in .jmx format.

Step 8  – Run the Test Plan

Click on the Green Triangle as shown at the top to run the test.

Step 9 – View the Execution Status

Click on View Result in Table to see the status of Run. A successful request will be of a Green colour in the Text Section.

Additional Tutorials

How to send POST requests in JMeter
JMeter Authorization with access token
How to generate JMeter HTML Report? 
Constant Throughput Timer in JMeter
How to generate JMeter HTML Report?

How to use Uniform Random Timer in JMeter

Last Updated On

HOME

In this tutorial, we will discuss the Uniform Random Timer in JMeter and its use in Load Testing.

Table of Contents

The sample request and response used in this tutorial is shown below:

Sample Request

{
    "name": "JMeter",
    "job": "Testing"
}

Sample Response

{
  "name":"Test",
  "job":"JMeter",
  "id":"955",
  "createdAt":"2023-07-27T15:46:18.038Z"
}

Create a Test Plan in JMeter


Step 1 –  Add Thread Group

  • Select Test Plan on the tree
  • Add Thread Group                                                                                                                               To add Thread Group: Right-click on the “Test Plan” and add a new thread group: Add -> Threads (Users) -> Thread Group

In the Thread Group control panel, enter Thread Properties as follows: We will take an example of row no 5

Number of Threads: 1 – Number of users connects to the target website
Loop Count: 10  – Number of times to execute testing
Ramp-Up Period: 1 – It tells JMeter how long to delay before starting the next user. For example, if we have 5 users and a 5 second Ramp-Up period, then the delay between starting users would be 1 second (5 seconds /5 users).

Step 2 –  Add HTTP Request Sampler 

The JMeter element used here is the HTTP Request Sampler. In the HTTP Request Control Panel, the Path field indicates which URL request you want to send


Add HTTP Request Sampler
To add: Right-click on Thread Group and select: Add -> Sampler -> HTTP Request

The below-mentioned are the values used in HTTP Request to perform the test

  • Name – Parameterized HTTP Request
  • Server Name or IP – reqres.in
  • Protocol – https
  • Method – POST
  • Path – /api/users

Step 3 – Add HTTP Head Manager

The Header Manager lets you add or override HTTP request headers like can add Accept-Encoding, Accept, Cache-Control

To add: Right-click on Thread Group and select: Add -> Config Element -> HTTP Read Manager

The below-mentioned are the values used in HTTP Request to perform the test
Content-type = application/json

Below is the image once HTTP Header Manager is added to the Test Plan.

Step 4 – Add a Uniform Random Timer

Step 6 – Adding Listeners to the Test Plan

Listeners – They show the results of the test execution. They can show results in a different format such as a tree, table, graph, or log file
We are adding the View Result in Table

View Result in Table – The View Result in Table listener displays information about each sample in the form of a table. 
To add: Right-click on Test Plan, Add -> Listener -> View Result in Table

Note – Don’t use “View Results Tree” or “View Results in Table” listeners during the load test, use them only during the scripting phase to debug your scripts.

Step 7 – Save the Test Plan

To Save: Click File Select -> Save Test Plan as ->Give the name of the Test Plan. It will be saved in .jmx format.

Step 8  – Run the Test Plan

Click on the Green Triangle as shown at the top to run the test.

Step 9 – View the Execution Status

Click on View Result in Table to see the status of Run. A successful request will be of a Green colour in the Text Section.

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Additional Tutorials

How to send POST requests in JMeter
JMeter Authorization with access token
How to generate JMeter HTML Report? 
Constant Throughput Timer in JMeter
How to generate JMeter HTML Report?

Constant Throughput Timer in JMeter

HOME

What is Throughput?

Throughput is calculated as requests/units of time. The time is calculated from the start of the first sample to the end of the last sample. This includes any intervals between samples, as it is supposed to represent the load on the server.

The formula is: Throughput = (number of requests) / (total time)

Suppose we want to run the load test with constant throughput in JMeter, then JMeter has a group of elements, which are called “Timers”.  And one of them has the obvious title – “Constant Throughput Timer”. That is what we need. 

What is Constant Throughput Timer?

This timer allows us to keep total throughput constant. Constant Throughput Timer is only capable of pausing JMeter threads in order to slow them down to reach the target throughput, so make sure you have enough threads in order to guarantee the desired amount of requests per second. Also, be aware that the Constant Throughput Timer is precise enough only on a minute level, so you need to properly calculate the ramp-up period and let your test run long enough. Of course, if the server is not able to handle such a load, the throughput will be lowered. Throughput may decrease if other timers contradict the Constant Throughput timer.

Constant Throughput Timer will introduce random delays between requests in such a way that a load/stress of required throughput is sent to the application.

Screenshot of Control Panel of Constant Throughput Timer

Create a Test Plan in JMeter

Step 1 –  Add Thread Group

Select Test Plan on the tree

Add Thread Group                     

To add Thread Group: Right-click on the “Test Plan” and add a new thread group: Add -> Threads (Users) -> Thread Group

In the Thread Group control panel, enter Thread Properties as follows: 

Number of Threads: 1 – Number of users connects to the target website

Loop Count: Infinite  – Number of times to execute testing

Ramp-Up Period:

Duration: 5 sec

Step 2 –  Adding JMeter elements  

The JMeter element used here is HTTP Request Sampler. In HTTP Request Control Panel, the Path field indicates which URL request you want to send

Add HTTP Request Sampler

 To add: Right-click on Thread Group and select: Add -> Sampler -> HTTP Request

Below-mentioned are the values used in HTTP Request to perform the test

Name – HTTP Request 

Server Name or IP – localhost

Port– 8010

Method– POST

Path– /demo/helloworld

Step 3 –  Add Constant Throughput Timer

To add: Right-click on Thread Group and select: Add -> Timer-> Constant Throughput Timer

Add Target Throughput: 600 (means 600 requests in 60 sec, so 10 requests per sec) Select Calculate Throughput based on – this thread only (More details about the option are present.

Step 4 – Adding Listeners to Test Plan

Listeners – They show the results of the test execution. They can show results in a different format such as a tree, table, graph, or log file

We are adding the View Result Tree listener

View Result Tree – View Result Tree shows the results of the user request in basic HTML format

To add: Right-click Test Plan, Add -> Listener -> View Result Tree

We are adding a Summary Report listener

Summary Report – The summary report creates a table row for each differently named request in your test. This is similar to the Aggregate Report, except that it uses less memory.

To add: Right-click Test Plan, Add -> Listener -> Summary Report

Step 5 – Save the Test Plan

To Save: Click File Select -> Save Test Plan as ->Give the name of the Test Plan. It will be saved as .jmx format.

Step 6  – Run the Test Plan

Click on Green Triangle as shown at the top to run the test.

Step 7 – View the Execution Status

Click on Summary Report to see the status of Run. As we can see in the summary report, 50 requests are executed as 10 requests per sec (10*5=50 requests).

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!