Performance Test of Web Application using Apache JMeter

Apache JMeter is one of the best open source tools for Load and Performance testing. It can be widely used for a variety of applications. In this blog, I would like to share how to do the performance and load testing of a web application using JMeter Recording Tests (GUI mode) on Windows Operating System. Before that, I would like to share about Apache JMeter features and installation process.

Apache JMeter Features:

  1. It has the ability to load and performance test many different applications, server, and protocol types such us HTTP, HTTPS, FTP, TCP, Web Services, etc.
  2. It allows to recording scripts, building, and debugging.
  3. It has compatibility with Windows, Linux, Mac OS, etc.
  4. Complete portability and 100% Java purity.

Downloading and Running Apache JMeter:

Requirements:

JMeter is a pure java application. It requires the system that is compatible with java and a fully compliant JVM 7 or higher version. Download and install Java Development Kit (JDK 7 or higher) from here.

Downloading JMeter:

  1. Download the latest version of Apache JMeter x.x from here.
  2. Choose Binaries file and either zip or tag file to download the JMeter

Configure JMeter

Running JMeter:

There are three modes to start JMeter

GUI Mode: It can be used for recording test script and running their script to JMeter itself. Run the Jmeter.bat file for Windows system and JMeter file for Linux. These files are found in the bin folder. After that, JMeter GUI will appear.

Command Line Mode (Non-GUI): For load testing, use this mode to get optimal results.

Server Mode: For distributed testing, use this mode to run JMeter in Sever on the remote node and control the servers from GUI.

Test Script Recording of Web Applications

Steps to Configure JMeter:

#1. Go to apache-jmeter-3.1/bin folder and start the jmeter.bat (Batch) file.

Configure JMeter

#2. Select “Test plan” on the Tree

Configure JMeter

#3. Right click on Test Plan and go to Add > Threads (Users) > Thread Group

Once Thread Group is added, configure the JMeter.

Jmeter configuration

Above figure shows JMeter configuration for 10 users, 5 seconds ramp-up and 1 Loop count.

Number of Threads: The number of users going to hit the server. Ramp-Up Period: Time given for each user to hit the server. For Example:

  • 100 users, 50 seconds ramp-up – start with 1 user, each second 2 users added
  • 100 users, 100 seconds ramp-up – start with 1 user, each second 1 user added

Loop count: Execute the same process ‘N’ number of times continuously and increase the loop count value.

#4. Right click on Thread Group and go to: Add > Config Element > HTTP Request Defaults

Jmeter configuration

Add the following three things to this window.

Server Name or IP: Server Name or IP is nothing but URL of the website on which you have to perform the load test.

Port Number: Add the default port number 8080 to the Port Number field. To change the number, edit it under Global settings.

Protocol: Here you can mention your required Protocol, http or https. Don’t mention as in Caps.

#5. Right click on Thread Group and go to Add > Logic Controller > Recording Controller

Jmeter configuration

You can watch recorded samples of your actions while you are browsing the web applications. Each Https request will be recorded.

#6. Right click on Thread Group and go to Add > Config Element > HTTP Cookie Manager

To use cookies on your web application, add HTTP Cookie Manager to the Thread group. Test Script Recorder #7. Next, select Workbench. Right click on Workbench and add the Recorder: Add > Non Test Elements > HTPP(S) Test Script Recorder

JMeter Proxy

Check whether the port 8080 is open or busy in your system. If it is busy, you should change to the other port number that is always open in your system. On HTTP(s) Test Script Recorder, click the Add button in “URL Patterns Include.” Enter “*”. It has to record everything.

To restrict any image types and web pages while recording the scripts, we need to enter the pattern in “URL Patterns Exclude” which is not being recorded in JMeter.

Example patterns: .*\.png .*\.html .*\.jpg

#8. Right click on “HTTP(S) Test Script Recorder” and Listener: Add > Listener > View Results in Tree.

JMeter Proxy

We need to add at least one Listener in the workbench so that we could see results of JMeter while recording. In JMeter, there are many listeners to view results. We can generate the report in Graph or Table.

Add Listeners: Right click on “Recording Controller” > Add > Listener > View Results in Table. Right click on “Recording Controller” > Add > Listener > Summary Report. Right click on “Recording Controller” > Add > Listener > Graph Results.

#9. Finally, click the “Start” button in the Script recorder window. Then the JMeter Proxy server will start on your system. When the JMeter starts, ApacheJMeterTemporaryRootCA.crt certificate will be created in the bin directory. Click OK and continue.

JMeter Proxy

Configure JMeter


Configure Browser to use the JMeter Proxy:

We will use Firefox to test the application. For this, we need to do the following proxy setup in the browser.

Steps to Configure Mozilla Firefox with JMeter Proxy:

  1. Open the browser. At that time, don’t close the JMeter window.
  2. Click Menu button from the Navigation bar.
  3. Choose “Options” menu.
  4. Click “Advanced” tab on the left and then select “Network” tab.
  5. Click on “Settings” button in the Connection section.
  6. Choose “Manual Proxy Configuration.”
  7. Type HTTP Proxy as localhost or enter IP Address of your system and then set port as 8080 (Check whether this port is free. If not change the port)
  8. Check “Use this proxy server for all protocols” option.
  9. Click “OK” button
  10. Click “OK” button again.

Now your browser is configured with JMeter Proxy server. Refer the below image to configure the Firefox browser.

Jmeter configuration

Now everything is configured and ready to start recording the user actions in JMeter.

Record the Script:

Before starting the recording, ensure that JMeter was started in your system.

  1. Open Firefox browser and type the URL of your application then hit enter.
  2. Do the actions whatever you want to test in the application.
  3. Now go to JMeter and click “Recording Controller” in the Thread Group. Here you can see the script for whatever actions you did in the browser.

Jmeter configuration

          4. Once you are done with the actions in the browser, click on “Stop” button of the HTTP(S) Test Script Recorder window in JMeter.

Run the Script:

We are ready to run the recorded script. Save the test plan. Run the Test Plan:  Press Ctrl + R (or) Click “Start” button.

While running the script, at the top right corner, a green color square box will display. Once it is completed, the box will change to Grey.

 Jmeter configuration

View Results:

Click on “View Results” in Tree under the Recording Controller.

Jmeter

Click on View Results in Table.

Configure JMeter

Click on Aggregate Graph > Graph

Configure JMeter

Click on Summary Report.

Configuring JMeter

In JMeter, we have to save recorded scripts in different formats like JMX, CSV, etc. We can upload the recorded script files to third party online load testing tools and get detailed and optimal results from there.

Online tools for load testing:

  1. Blaze meter  -> https://www.blazemeter.com
  2. Redline13  -> https://www.redline13.com
FacebookTwitterGoogle+Share