How to Optimize Performance Testing with Apache JMeter and Resources Monitoring Using DStat

How to Optimize Performance Testing with Apache JMeter and Resources Monitoring Using DStat

In a dynamic work environment, performance testing is the only way to ensure you are on top of your game. This non-functional testing is performed to determine system parameters such as speed, stability and scalability under various workload conditions and is a good indicator of your software quality.

Here are the primary goals of performance testing and what this seeks to determine:

  • Speed – How quickly the application responds
  • Scalability – How much maximum user load the application can handle
  • Stability – How it performs under varied load conditions

While there may be many tools and technologies to check for software performance, it is critical to understand how these may align with your IT budgets and spend, and key business goals. JMeter is a test tool from Apache that is used to analyze and measure the performance of applications, different software services and products.

In this blog, we take a closer look at these tool and how it can be maximized for testing the performance of your software applications.

Getting to know the Apache tool

The JMeter tool is an open-source software entirely written in Java, used to test both web and FTP applications if the system supports a Java Virtual Machine (JVM).

Here are some of its key features:

  • Ability to load and test different types of applications like HTTP, HTTPS, FTP, and SOAP/ REST web services
  • In-built functions for inputs and data manipulation to conduct a test
  • Command-line mode/Non-GUI to load test from any Java-compatible OS including Linux, Windows and Mac OSX
  • Ability to view and analyze the results of the request in graphical, table and tree formats with JMeter Listener
  • Highlighted correlations for any kind of response data formats like HTML, JSON and XM

Now that you know the USPs of this amazing tool, let’s get started on installations.

Installing Apache JMeter


Step 1: Install Java 8

Download the latest Java 8 from the Oracle website.
Run the Java installer package.
Verify the installed Java version by running this command-on-command prompt java -version

Step 2: Download Apache JMeter

Download the latest version of Apache JMeter from
Download the Binaries zip file.

Step 3: Extract Apache JMeter

Find the downloaded zip file and extract it to your desired directory.
Downloaded zip file
For example, I extract the to C:\Softwares\.
Apache JMeter extracted directory
Now go to /bin folder. You will find jmeter.bat./bin directory
Double click on this file. The Apache JMeter GUI will be opened. You can create a shortcut for it on your desktop too. You are now ready to use JMeter.

Sample performance test plan using Apache JMeter

  • Verify the response time is not more than 5 seconds when 30 users access the website simultaneously.
  • Check CPU and memory usage of the application and the database server under peak load conditions.
  • Create a sample test in Apache JMeter. Here we will create a sample test to test a specific request in the web application. We will execute the single request using 30 concurrent users

Step 1: Start JMeter.

  • Open the JMeter window by clicking on C:\Users\AB-1234\Desktop\apache- jmeter-4.0\bin\jmeter.bat file

Step 2: Give a name to the test plan.

  • You can give specific name to the test plan.

Step 3: Add a thread group.

  • Add the Thread Group element by first selecting the test plan, clicking your right mouse button to get the Add menu, and then select Add → Thread Group.
  • The Thread Group tells JMeter the number of users you want to simulate, how often the users should send requests, and how many requests they should send.
  • The Ramp-Up Period field leaves the default value of 1 second. This property tells JMeter how long to delay between starting each user.
  • Enter the Loop Count that tells JMeter that how many times you want to repeat your test.

Step 4: Add Pre-Processor User Parameters.

  • Add the Thread Group element by first selecting the ThreadGroup, clicking your right mouse button to get the Add menu, and then select Add → Pre-Processor → User Parameters.
  • Pre-Processors are JMeter elements that are used to execute actions before the sampler requests are executed in the test scenario.
  • User Parameters are used to define values for the variables before they are used in the Samplers.
  • Here we have added the value for the Authentication token and the server’s name as a user parameter.

Step 5: Using an HTTP Header Manager

  • Add the HTTP Header Manager element by first selecting the ThreadGroup, clicking your right mouse button to get the Add menu, and then select Add → Config Element → HTTP Header Manager.
  • The HTTP Header Manager allows you to customize the information JMeter sends in the HTTP request header. This header includes properties like “User-Agent”, “Pragma”, and “Referer”.
  • This allows one to set up a default set of headers like here we have used Content-Type, Authorization, etc. and apply adjustments to samplers.

Step 6: Add an HTTP Request sampler.

  • Add the HTTP Header Manager element by first selecting the ThreadGroup, clicking your right mouse button to get the Add menu, and then select Add → Sampler → HTTP Request.
  • The HTTP Request sampler lets you send an HTTP/HTTPS request to a web server. You can add a different field required to execute an HTTP request like the server’s name, port, the request method, a path of the request, and the parameters or the Jason body required to execute the HTTP request.
  • If you are going to send multiple requests to the same web server, you can use an HTTP Request Defaults Configuration Element, so you do not have to enter the same information for each request.

Step 7: Adding the Listener to view the test results

  • The final element you need to add to your Test Plan is a Listener. This element is responsible for storing all the results of your HTTP requests in a file and presenting a visual model of the data.
  • Add the JMeter Listener element by first selecting the HTTP request, clicking your right mouse button to get the Add menu, and then select Add → Listener → Summary Report.
  • There are multiple Listeners that we can add to see the test results. Some of them present the results in a tree, a table, a summary report, or graph results.

Step 8: Save and run the test plan

  • With the setup complete, we can now execute the test plan. Simply select Run from the menu and select the Start option.
  • Apache JMeter asks us to save the test plan in a disk file before starting the test. This is important if you want to run the test plan multiple times. You can opt for running it without saving too

Step 9: View the output

  • We can view the output by using differently configured Listeners tosee the results in tree listener in detail. The green color against the name Get All Staff List indicates success.

  • The first tab is the Sampler Results. It shows JMeter data as well as data returned to the webserver
  • The second tab is Request, which shows all the data sent to the web server as part of the request.
  • The last tab is Response data. In this tab, the Listener shows the data received from the server in text format.

The Resource Monitoring Tool for Linux servers — DStat

Some of the popular and frequently-used system resource generating tools available on the Linux platform include vmstat, netstat, isostat, ifstat and mpstat. They are used for reporting statistics from different system components such as virtual memory, network connections and interfaces, CPU, input/output devices. DStat is a powerful, flexible, and versatile tool for generating Linux system resource statistics and can be used as a replacement for all the tools mentioned above. It comes with extra features, counters and is highly extensible. In fact, users who are adept at Python can build their own plugins.

Here’s why DStat is a winning tool among users:

  • Joins information from vmstat, netstat, isostat, ifstat and mpstat tools
  • Displays statistics simultaneously
  • Supports summarizing of grouped block/network devices
  • Displays interrupt per device
  • Works on accurate timeframes, no time shifts when a system is stressed
  • Supports colored output and indicates different units in different colors
  • Supports exporting of CSV output to Numeric and Excel documents

DStat is available for installation from default repositories on most Linux distributions. You can install and use it for monitoring a Linux system in the process of performance tuning tests or troubleshooting exercises.

Here’s how you can install DStat on Linux systems

Use the simple Linux commands listed below to install DStat:

Example of monitoring resource utilization using the DStat tool

1. After successful installation of DStat, simply fire DStat without any option to get the below results:

$ DStat

We can see the below-mentioned parameters in the output:We can see the below-mentioned parameters in the output:

c: cpu: Total cpu usage

d: disk: Disk Utilization

n: net: Total Network usage

g: page: page stats

y: sys: system stats

2. View detailed information about Memory, which includes (used, buffer, cache & free), Swap (used & free) & Virtual Memory (allocated, free, major page fault & minor page fault) usage.

$ DStat –mem –swap –vm

3. You can view detailed information about each CPU (include cpu0, cpu1, etc) and total usage. It displays each CPU (user time, system time, idle time, steal time and wait time) process activity.

$ DStat -C 0,1,2, total

4. View detailed information about disk utilization (read and write) and disk I/O (read and write) utilization for a particular disk. If you want to check total disk utilization and I/O, use this:

DStat –disk –io

$ DStat –disk –io -D sda

5. Use the below command to capture all the status in one go (MeasureCPU, Memory, Swap and iostat)

$ DStat -tT -v -fs -n

Process stats: Number of running (run), blocked (blk) and new (new) spawned processes

Memory stats: The amount of used (used), buffered (buff), cached (cach), and free (free) memory

Paging stats: Number of times information is copied into (in) and moved out (out) of memory

Disk stats: Total number of reading (read) and write (writ) operations on disks

System stats: System statistics to measure the performance of system CPU and the storage subsystem

CPU stats: CPU usage by a user processes, system processes, as well as the number of idle and waiting processes

Network stats: Total amount of bytes received (recv) and sent (send) on network interfaces

6. By default, the delay is 1 second and the count is UNLIMITED if you want to display statistics every 2 seconds delay with 10 counts, on any combination as per your requirement. The below combination shows about CPU and process statistics every 2 seconds with 10 counts.

$ DStat –time –cpu –proc 2 10


7. If you want to store the reports to file for further investigation and to plot the graphs, you can do so by using the below format with any combination:

$ DStat -tT -v -fs -n –output /tmp/node1stat.csv –noheaders

From the above-downloaded CSV file, we can plot resource utilization graphs as per our requirements.

As illustrated in this blog, JMeter is suitable for performance testing of a web application, where we can easily create a test plan and verify the results. We have also seen that DStat is a versatile tool that is used to monitor all-in-one system resources utilization.

GS Lab is the technology partner to help you undertake seamless performance testing of your software applications. Our spectrum of services ranges from performance automation testing, capacity planning, competition benchmarking, to performance monitoring and consulting.

Learn more about our performance engineering, testing and consultation capabilities at


Nitin Nimase | Senior Software QA Engineer | Connected Experience | GS Lab

Nitin Nimase serves as Senior Software QA Engineer at GS Lab for Connected Experience Practice. Over his years of experience in software testing and quality assurance in multiple domains like storage, telecommunication, and healthcare, he has contributed to Software testing; he has handled end-to-end qualification of various enterprise software products and solutions in agile development.