JMeter Complete Element Reference – Part I

In the previous article, we have learned about recording a test script using JMeter HTTP proxy server. So, lets dive deep into numerous elements which can be used for building exceptional test scripts using multiple protocols and many more.

JMeter Element Reference

Apache JMeter has wide variety of elements which are defined for a specific purpose. Since JMeter is pure java desktop application and provides a feasible way  of additional custom packages or plugins available on the net  which are used for multiple purposes such as resource monitoring, running selenium scripts and many more. Below are the configuration elements which Apache JMeter supports.

elements

In this article, we will discuss about “Threads(Users)”.  Studying all the elements at one go is an invitation to confusion and boredom.

Threads(Users):

A single Thread defines a single virtual user performing a business process or an activity . The major elements under this section can be:

  • Thread Group
  • setUp Thread Group
  • tearDown Thread Group
  • stepping Thread Group
  • Ultimate Thread Group

Thread Group

Thread group elements are the beginning points of any test plan. All controllers and samplers must be under a thread group. Other elements, e.g. Listeners, may be placed directly under the test plan, in which case they will apply to all the thread groups. As the name implies, the thread group element controls the number of threads JMeter will use to execute your test. The controls for a thread group allow you to:

  • Set the number of threads
  • Set the ramp-up period
  • Set the number of times to execute the test

Each thread will execute the test plan in its entirety and completely independently of other test threads. Multiple threads are used to simulate concurrent connections to your server application.

The ramp-up period tells JMeter how long to take to “ramp-up” to the full number of threads chosen. If 10 threads are used, and the ramp-up period is 100 seconds, then JMeter will take 100 seconds to get all 10 threads up and running. Each thread will start 10 (100/10) seconds after the previous thread was begun. If there are 30 threads and a ramp-up period of 120 seconds, then each successive thread will be delayed by 4 seconds. Ramp-up needs to be long enough to avoid too large a work-load at the start of a test, and short enough that the last threads start running before the first ones finish (unless one wants that to happen).

Start with Ramp-up = number of threads and adjust up or down as needed.

By default, the thread group is configured to loop once through its elements. Based on the requirement we can change the loop count i.e if You want to run your test for 100 iterations, just set loop counter to 100. If you want run the test for very longer time, just check the button “forever” test will be run until interruption.

JMeter a provides an advanced functionality i.e “Scheduler”. To schedule a test, Click the check-box at the bottom of the Thread Group panel to reveal extra fields in which you can enter the start and end times of the run. When the test is started, JMeter will wait if necessary until the start-time has been reached. At the end of each cycle, JMeter checks if the end-time has been reached, and if so, the run is stopped, otherwise the test is allowed to continue until the iteration limit is reached. The advantage of this functionality is, complete control to schedule a test is in our hands. Lets say you wanted to soak test an application i.e you wanted to see how my applications behaves when the server receive continuous concurrent hits for an entire day.Using this scheduler, you can schedule a test for an entire day and you can check the application behavior.

The controls for a thread group allow you to Set the number of threads for each group.

For example, if you set the number of threads as 100; JMeter will create and simulate 100 user requests to the server under test

 

setUp Thread Group

A special type of Thread Group that can be utilized to perform Pre-Test Actions. The behavior of these threads is exactly like a normal Thread Group element. The difference is that these type of threads execute before the test proceeds to the executing of regular Thread Groups.

set

 

tearDown Thread Group

A special type of Thread Group that can be utilized to perform Post-Test Actions. The behavior of these threads is exactly like a normal Thread Group element. The difference is that these type of threads execute after the test has finished executing its regular Thread Groups.

tear

 

Stepping Thread Group

This is a custom thread group available in “Standard Set” package.  JMeter have only one out-of-the-box option for threads (users) scheduling: simple ramp-up. In details this is the only custom thread group which is used to ramp-up threads(Users).  Stepping Thread Group adds to JMeter thread scheduling similar to LoadRunner’s. The features of this thread group can be:

  • preview graph showing estimated load.
  • initial thread group delay to combine several thread group activities.
  • increase load by portions of threads (users) with ramp-up period.
  • configurable hold time after all threads started.
  • decrease load by portions.

Following screenshot shows Stepping Thread Group set to generate load increasing by 10 users each 2 minutes:

Lets have a glance at the thread scheduling parameters:

  • The total number of threads to be run are 100 i.e Apache Jmeter creates a 100 virtual users on the fly.
  • First, wait for:  is set to 15 sec i.e All the actual virtual users will wait for 15 sec to fire requests to the server.
  • then start:  This section indicate for every 120 seconds invoke 10 users and do the activity for 180 sec.
  • Finally Stop: is set to 5 per every 15 sec which means every 15 sec 5 users will be terminated or stops sending requests to the server.

Ultimate Thread Group

Using Ultimate Thread Group we can apply conditional load on the server. Suppose you want to perform load for 100 users in different slots of time with different users. For example 10 users with for first 20 seconds and then 10 users for another 30 seconds and so on.. We need to use Ultimate Thread Group.

So to configure Jmeter for distributed load follow the steps mentioned below:

1)  Go to Add –> Threads (Users) –> jp@gc – Ultimate Thread Group.

Ultimate Thread Group Configuration for Distributed Load-

1)  Once the Ultimate Thread Group is added The page will look like-

2)  Click on Add Row button to add more rows for different number of users.

3) I am going to add 4 Rows for the users 10, 20, 40, 50 . So totally  (10+20+40+50) 120 users.

4)  Please refer the configuration give below-

Start Thread Count- The thread will start one by one. For Ex- First Thread and then second thread and then third thread and so on up to tenth thread. So we have totally 10 users in the first row that mean we are going to load for 10 users first.

Initial Delay- Initial delay is the time for the first user hit the server after Jmeter starts. This time is nothing but just after how many seconds you want to hit the server first time.

Start-up time- Start up time will be divided among each user as (Start Threads Count / Start-up Time ). So here it is (10/10). It mean we are giving 1 sec for each thread or user to hit the server. So once the first user will hit the server after initial delay of 5 sec then after each user start hitting the server after every 1 sec and it will reach up to 10 seconds.

Hold Load For- Once all the 10 users activated the load will hold up to 10 seconds. Shutdown Time- After 10 seconds total time to stop the hitting server. So here it is 5 seconds. It mean within 5 seconds all the user will stop the hitting server or all the threads will be stopped.

Now I have given load for 10 users and configured.

 Here is the screen shot for other 20+40+50 users.

Once you will run the Jmeter first 10 users will perform load and complete. After delay for 5 seconds 20 users will perform load, again after delay for 5 seconds 40 users and finally after delay of 5 seconds 50 users will perform load.

If you enjoy reading article then you can subscribe our updates for FREE, just add your email id . I will keep on updating the article for latest testing information. Subscribe and stay tuned for updates, there’s lot more to come.

🙂 Happy Performance Testing !! 🙂

 

 

Advertisements

7 thoughts on “JMeter Complete Element Reference – Part I

  1. Hi how to use ultimate thread group and stepping thread group,

    i was using this but cant get the result, can you please send me the screen shot of sample, using google sign in.

    i followed this steps:

    add jp@gc ultimate tread group,
    under give the local host name,
    then add listener , tree view

    now run the grout, no responses.

    can you please tell me the full screenshot of this test scenario…..

  2. Hi how to use ultimate thread group and stepping thread group,

    i was using this but cant get the result, can you please send me the screen shot of sample, using google sign in.

    i followed this steps:

    add jp@gc ultimate tread group,
    under give the local host name,
    then add listener , tree view

    now run the grout, no responses.

    can you please tell me the full screenshot of this test scenario…..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s