Thread Group and samplers for JMeter

Thread Group is a group of users which will be hitting the server under test either concurrently or in some predefined sequence. Thread Group can be added to Test Plan by right clicking the test plan. JMeter is all “Right Click stuff”, you get all the options on the right click.

You can rename Thread Group name to your own. Just change the name and click anywhere outside the Test Plan window, you would see the name getting changed.

Please see below screenshot for adding Thread Groups

(Note: Click on any image for enlarged view)

It is very important to configure your thread group as per the test conditions.

For example, if you want to test how a web server behaves when 100 user hits it concurrently, you can set Thread Group as below:

Basically, there are three main parameters which must be configured to generate actual load or virtual users:
  • Number of Thread(Users) – It defines the number of virtual users. For testing purpose, we should generate only a limited amount of load as generating huge volume at once would mean consuming lot many threads which can ultimately lead to high CPU utilization.
  • Ramp Up Period – This field is very important in controlling the load generation. Ramp up period defined the amount of time in which the total load will be generated.
Example 1:
Total Number of UsersRamp UP Period
101 sec
  • It means all 10 users will be hitting servers concurrently as soon as a test is run
Example 2:
Total Number of UsersRamp UP Period
1010 sec
  • You all must have noticed the “Scheduler” checkbox in above screenshot. In case you want your test to run at a specific time later then you can set the timings as you can also see in the below screenshot. It means that every 1 sec, a new user will be hitting server. The load will not be concurrent but will be in increments. By the 10th second, all user would have hit the request.
  • Loop Count– It defines the number of times Thread Group will execute. If you check the Forever check box your test will run forever unless you manually stop it. This can be used to test something like “If your server doesn’t crash on continuous load for few minutes”.

 Samplers

So, how does a Jmeter knows what type of request has been sent to server???
  • It is through Samplers. Samplers are a must to add to a Test Plan as only it can let Jmeter know what type of request need to go to which server and with any predefined parameters or not. Requests could be HTTP, HTTP(s), FTP, TCP, SMTP, SOAP etc.

Samplers can only be added to Thread Group not directly under Test Plan as Thread Groups need to use a sampler to send a request to server URL under test. The sampler can be added by path Thread Group -> Sampler -> HTTP Request.

HTTP Requests

These are the most common requests sent to the servers. Say, for example, we want 100 users to hit https://www.google.com concurrently, this can be done as described in below screenshot:

  • The path is the navigation inside the main website. For example, if we want to hit http://www.google.com/gmail then we can set “/Gmail” in path and rest remains the same
  • Need not type “www” in the server name
  • Port Number is used if you are using any proxy server
  • Timeout Connect and Response can be set if you want to have a benchmark on your server connection time and response time. Your request will fail if your server takes more time to send response than configured one
  • You can also configure parameters to send with your request. For example: In some cases, you may need to send Authorization Token with your request, so you made add them in HTTP Request as below:
FTP Requests
Path-> Test Plan-> Thread Group-> Sampler-> FTP Request

FTP stands for File Transfer Protocol and it is used to upload or download a file from the server. JMeter’s threads send requests to FTP servers to upload or download files from there and measures the performance.

  • Local File is the location where you need to save the downloaded file
  • Use GET option if you are downloading from FTP server
  • User POST option if you are uploading any file on FTP server

We have lot many listeners which will be covered when we go through some real Test Plans consisting Samplers, listeners, config elements etc.

Leave a Reply

Your email address will not be published. Required fields are marked *