JMeter Elements & Components: Thread Group, Samplers

โšก Smart Summary

JMeter elements are the building blocks of every test plan: Thread Groups create virtual users, Samplers send the requests, Listeners display results, and Configuration Elements supply the defaults and data those requests need.

  • ๐Ÿ”˜ Thread Group: Each thread represents one virtual user driving the application under test.
  • โ˜‘๏ธ Samplers: Decide the protocol of the request โ€” FTP, HTTP, JDBC, SMTP and more.
  • โœ… Listeners: Render results as a graph, a tree, a table or a log file.
  • ๐Ÿงช Configuration Elements: Set defaults and variables that samplers reuse across a whole test.
  • ๐Ÿ› ๏ธ Data-driven runs: CSV Data Set Config feeds different credentials to every simulated user.
  • โšก Modern equivalents: The BSF Sampler has been dropped; current releases script through JSR223 and Groovy.

JMeter Elements: Thread Group, Samplers, Listeners and Configuration Elements

What is Element in JMeter?

The different components of JMeter are called Elements. Each Element is designed for a specific purpose.

The figure below gives some common elements in JMeter and shows how they sit under a Thread Group.

JMeter element hierarchy diagram with Thread Group above Samplers, Logic Controllers, Listeners, Configuration Elements, Assertions, Timers and Processors

Studying all the components in one go is an invitation to confusion and boredom. Here, we will discuss the must-know components before you can start testing in JMeter.

The remaining components will be discussed as and when they are used in the succeeding tutorials. The elements discussed in this tutorial are listed below.

Thread Group

A Thread Group is a collection of threads. Each thread represents one user using the application under test. Basically, each thread simulates one real user request to the server.

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, as the diagram below illustrates.

Diagram of a JMeter Thread Group simulating User 1 to User 100, each sending a request to the application under test

The Thread Group panel also carries a ramp-up period, which spreads the start of those threads over time instead of launching every user at once.

Samplers

As we already know, JMeter supports testing HTTP, FTP, JDBC and many other protocols.

We also know that Thread Groups simulate user requests to the server.

But how does a Thread Group know which type of request (HTTP, FTP and so on) it needs to make?

The answer is Samplers.

The user request could be an FTP Request, an HTTP Request, a JDBC Request and so on. The figure below lists the samplers covered in this tutorial.

Tree diagram listing JMeter samplers: FTP Request, HTTP Request, JDBC Request, BSF Sampler, Access Log Sampler and SMTP Sampler

FTP Request

Let us imagine you want to performance test an FTP server. You can use an FTP Request sampler in JMeter to do this task. This controller lets you send an FTP “download file” or “upload file” request to an FTP server.

Diagram showing JMeter sending an FTP request to an FTP server to upload or download a file

For example, if you want to download a file “Test.txt” from an FTP server under test, you need to configure some parameters in JMeter as in the figure below.

FTP Request sampler panel with ftp.example.com as the server, port 21, Test.txt as the remote file and anonymous login

The panel sets the server to ftp.example.com, port 21, the remote file to Test.txt and the get(RETR) option, so JMeter sends an FTP command to that server and downloads the file.

HTTP Request

This sampler lets you send an HTTP/HTTPS request to a web server.

Consider the example below. JMeter sends an HTTP request to the Google website and retrieves HTML files or images from it.

Diagram of JMeter sending an HTTP request to Google Sites and receiving HTML and images in return

In the tutorial JMeter Performance Testing, we will explain more about this HTTP Request. It is the sampler most web application testing work relies on.

JDBC Request

This sampler lets you execute database performance testing. It sends a JDBC Request (an SQL query) to a database.

Diagram of JMeter sending an SQL query to a database server and receiving the result

For example, a database server has a field test_result stored in a table named test_tbl. You want to query this data from the database server, so you can configure JMeter to send a SQL query to this server to retrieve the data.

JDBC Request panel with Query Type set to Select Statement and the query select test_result from test_tbl where id = 1

The Query Type here is Select Statement and the query reads select test_result from test_tbl where id = 1. A JDBC Connection Configuration element must supply the pool that the Variable Name field points at.

BSF Sampler

This sampler allows you to write a sampler using a BSF scripting language.

Here is an example of a BSF Sampler in JMeter, with fields for the script language, the parameters passed to the script and either an inline script or an external script file.

BSF Sampler panel with fields for script language, parameters, an external script file and the inline script body

Deprecation note: the BSF family of elements was deprecated in favour of the JSR223 elements and no longer appears in the JMeter component reference. On current releases, use the JSR223 Sampler with Groovy, which compiles the script and performs far better under load. The panel above is kept here because older test plans still contain it.

Access Log Sampler

This sampler allows you to read access logs and generate HTTP requests. The log entries could be images, HTML, CSS and so on.

Access Log Sampler panel showing default server and port fields, the TCLogParser plugin class and the log file location

The Parser field defaults to org.apache.jmeter.protocol.http.util.accesslog.TCLogParser, and the Log File Location field points JMeter at the log you want replayed.

SMTP Sampler

If you want to test a mail server, you can use the SMTP Sampler. This sampler is used to send email messages using the SMTP protocol.

SMTP Sampler panel with server settings, mail addresses, authentication and security options, and message settings

The panel groups server settings, mail addresses, authentication and message settings, and it prints the default ports beside the Port field: SMTP 25, SSL 465 and StartTLS 587.

Listeners

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

Diagram showing a Listener fanning results out into graph, tree, table and report views

The Graph Results listener displays the server response times on a graph, with the sample count, average, deviation, throughput and median printed underneath.

Graph Results listener plotting response times with data, average, median, deviation and throughput series

View Results Tree shows the result of each user request in basic HTML format, with a Sampler result tab reporting load time, latency, size and response code.

View Results Tree listener with a request list on the left and the Sampler result tab showing response code 200

View Results in Table shows a summary of the test result in table format, one row per sample.

View Results in Table listener with columns for sample number, start time, thread name, label and sample time

A log file records the same summary as text, which is what you keep when a test runs without the GUI.

Aggregate log summary listing sampler labels with sample counts, averages and a TOTAL row

Best practice: GUI listeners consume memory and skew results, so run real load tests in non-GUI mode and open the saved results file afterwards.

Configuration Elements

Configuration Elements set up defaults and variables for later use by samplers.

The figure below shows some commonly used configuration elements in JMeter.

Tree diagram of JMeter configuration elements: CSV Data Set Config, HTTP Cookie Manager, Login Config Element, HTTP Request Defaults and FTP Request Defaults

CSV Data Set Config

Suppose you want to test a website for 100 users signing in with different credentials. You do not need to record the script 100 times. You can parameterize the script to enter different login credentials. This login information (for example, username and password) could be stored in a text file. JMeter has an element that allows you to read different parameters from that text file. It is “CSV Data Set Config”, which is used to read lines from a file and split them into variables.

JMeter test plan tree with CSV Data Set Config selected under a Login controller alongside HTTP Request Defaults

This is an example of CSV data. It is a text file that contains the user names and passwords used to log in to your target website.

Text file csv_data.txt holding four comma-separated rows of username, password and cookie length values

HTTP Cookie Manager

Let us understand this with an example.

You used your browser (Firefox, Chrome and so on) to browse www.google.com.

You log in with your user name and password.

Your user name and password will be stored on your computer as cookies.

Next time, when you visit www.google.com, you do not need to log in again, because your browser will use your cookies as user data to log in.

The HTTP Cookie Manager has the same feature as a web browser. If you have an HTTP Request and the response contains a cookie, the Cookie Manager automatically stores that cookie and uses it for all future requests to that particular website.

HTTP Request Defaults

This element lets you set default values that your HTTP Request controllers use.

For example,

You are sending 100 HTTP requests to the server google.com.

You would have to enter the server name google.com manually for all 100 requests.

Instead, you could add a single HTTP Request Defaults element with the “Server Name or IP” field set to google.com, as shown below.

HTTP Request Defaults panel with google.com as the server name, port 80 and connect and response timeouts

No need to type it 100 times. This element will be explained in detail in the tutorial JMeter Performance Testing.

Login Config Element

The Login Config Element lets you add or override user name and password settings in samplers.

For example, you want to simulate one user logging in to the website www.facebook.com with a user name and password. You can use the Login Config Element to add this user name and password setting in a user request.

Login Config Element panel with guru99 entered as the user name and a masked password field

The Login Config Element vs. the CSV Data Set Config

Login Config Element CSV Data Set Config
Used to simulate one user login Used to simulate multiple user logins
Suitable for login parameters only (user name and password) Suitable for large numbers of parameters

Between them, these two elements cover almost every credential scenario you meet in performance testing tools work.

FAQs

It tells JMeter how long to take before all threads are running. Ten threads with a 100-second ramp-up start ten seconds apart. Too short a ramp-up floods the server and produces failures that no real user would ever cause.

Timers insert a pause between requests so the simulated load resembles real browsing instead of a flood. Assertions check each response, marking a sample failed when the status code, text or duration does not match what you specified.

They group and branch the requests beneath them. A Loop Controller repeats its children, an If Controller runs them conditionally, and a Transaction Controller reports the whole group as one timed step in the results.

No. Listeners such as View Results Tree buffer every sample and distort the numbers they report. Run the test in non-GUI mode, write results to a file, then load that file into a listener once the run has finished.

Configuration elements and pre-processors are applied first, then the sampler runs, then post-processors, assertions and listeners. Scope also matters: an element placed at plan level applies to every request beneath it.

It is useful for pattern spotting. Feeding a results file to an assistant surfaces the slowest labels, error clusters and response-time trends far faster than reading rows. Always confirm the finding against the raw samples before acting.

Yes. It drafts Groovy for extracting values, building payloads and setting variables inside a JSR223 element. Check every suggestion, because it often reaches for the deprecated BeanShell API or variables that JMeter does not expose.

One Thread Group and one sampler. Everything else is optional. In practice a listener is added so results are visible, and defaults or a data file are added once the same values start repeating across requests.

Summarize this post with: