paint-brush
Performance Testing of a Single-node Server and a Two-node Cluster with Apache JMeterby@iflexion.com
5,043 reads
5,043 reads

Performance Testing of a Single-node Server and a Two-node Cluster with Apache JMeter

by IflexionApril 4th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

<strong>About Performance Testing</strong>

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Performance Testing of a Single-node Server and a Two-node Cluster with Apache JMeter
Iflexion HackerNoon profile picture

About Performance Testing

Performance testing is a method of identifying whether software (a web application) is capable to handle a high load, among other possible performance issues. Therefore, the ultimate goal of a performance test is to analyze the overall performance against heavy loads. Apache JMeter is an open-source tool that can be used exactly for this purpose.

What is a Single-node Server?

This is the case when a server runs on a single machine only. If the server crashes due to some issue, there will be a downtime until the issue is fixed.

What is a Two-node Cluster?

A two**-**node cluster is a setup where two servers are configured with high availability. If clustering is used, there won’t be downtime due to a server crash. The advantage of having your servers in a cluster environment is that if one server is unavailable due to a crash or some other failure, the other node will operate as the primary one and the system will be operated without causing downtime for users.

Why Apache JMeter Is the Best Tool for It

Apache JMeter enables test performance for static and dynamic resources. Static resources include JavaScript, HTML, and others. Dynamic resources include JSP, Servlets, AJAX, and more. In addition, Apache JMeter has more properties that make it a suitable tool for performance and load testing:

· Overall performance analysis presented as a report

· A performance testing report containing analysis of different attributes, such as response time, page load time, throughput, error rate, and more

· Optimization suggestions provided in a report

· Graphical analysis reports with metrics such as transaction per second, hits per second, etc.

· Ability to identify the maximum number of concurrent users that can be handled without the server crashing

· Ability to extract data from a number of response types such as HTML, JSON, XML, etc.

· Support of an extensible core with pluggable samplers, scriptable samplers, pluggable timers, and visualization plugins

· Ability to integrate with any third-party open-source libraries such as Maven, Gradle, and Jenkins

· Support of multithreading frameworks

A performance test can be carried out in either of the two ways mentioned below:

Load Testing: this is a testing type that models the expected usage by simulating multiple concurrent user accesses.

Stress Testing: this is a testing type used to identify the maximum load that can be handled by the server. When the load goes above the benchmark, the server may start responding slowly.

In the following, we will see how we can measure server performance using Apache Jmeter using the standard practice adopted at A1QA. Further, I will explain how this can be extended to test the performance of two servers running in parallel in a two-node cluster environment. You can use any web app that you are familiar with to conduct the test. I will be using eBay for this purpose.

This process will consist of five main steps:

  1. Add a Thread Group
  2. Add necessary JMeter Elements
  3. Add Graph Results
  4. Run the test
  5. Obtain and analyze the results

1. Let’s Get a Thread Group

The Thread Group element will be the initial step of the test plan. The Thread Group is a set of threads that will be executing the same scenario. This defines a pool of users participating in a particular test case. Other samplers and controllers need to be included inside the Thread Group.

This article assumes that you have installed Apache JMeter on your machine. If not, please refer to this official guide for more details.

How to add a Thread Group:

  1. Start Apache JMeter
  2. See the Test Plan option on the left-hand side
  3. Right-click on the Test Plan option
  4. Select the Add option
  5. Select the Threads (Users) option
  6. Select the Thread Group option

After adding a Thread Group, you will see the Thread Properties section where you can control the properties of the Thread Group.

Number of Threads: 100 (number of users connected to the web app: 100)

Loop Count: 10 (number of times to execute testing)

Ramp-Up Period: 100 (time required for JMeter to get all the threads up and running. Also, this is explained as the delay time before the start of the next user.)

2. Let’s Add Necessary JMeter Elements

We will be using two elements in this use case. They are HTTP Request Default and HTTP Request.

How to add an HTTP Request Default

You can add an HTTP Request Default sampler in the following way:

1. Right-click on the Thread Group from the tree node

2. Select the Add option

3. Select the Config Element option

4. Select the HTTP Request Defaults option

You can see input values for the server IP and Port on the control panel. This is where you will input the IP and the port relevant to the web app for which you are carrying out the performance test. In this tutorial, I will be using the IP of eBay.

How to add an HTTP Request

You can add an HTTP Request sampler in the following way:

1. Right-click on the Thread Group from the tree node

2. Select the Add option

3. Select the Sampler option

4. Select the HTTP Request option

After adding the HTTP Request Sampler, you can see the Path field as shown in the image below. You can input a specific path to which you need to send the HTTP Request. For example, if you need to send the request to the Daily Deals section in eBay, you can check the path address relevant to that section from the website and input it under the path section:

Path: /globaldeals

So if you input /globaldeals for the path section, JMeter will send the HTTP Request to the complete URL https://www.ebay.com/globaldeals. If the path field is blank, it will send the request to https://www.ebay.com.

I will keep the path-field blank. So, the requests will be sent to https://www.ebay.com

3. Let’s Add Graph Results

You can use Graph Result Listener to observe the test results in the following way:

1. Right-click on Test Plan

2. Select Add

3. Select Listener

4. Select Graph Results

4. Let’s Run the Performance Test

Before running the test, you need to save your test plan by giving a name such as Perf-test.jmx. Then click on the green mark in the toolbar to run the test.

5. Let’s Obtain and Analyze the Results

While running the test, you can observe the test results which are displayed as Graphs in real time. You can see the graph that shows the performance results obtained for the sample use case we tried, in which 100 users accessed eBay server.

The statistics displayed at the bottom of the graph according to their colours:

● Black shows the total number of current samples sent.

● Blue shows the average value for the total number of samples sent.

● Red shows the standard deviation.

● Green shows the throughput rate (This is responsible for the total number of requests per minute that the server handled)

To gain an idea about the performance of the eBay server, we need to focus on two parameters: throughput and deviation.

Throughput is the ability of the server to handle a heavy load. The higher this value, the better performance of the server.

In this sample test, the throughput of the eBay server is 199.609/min. This means the eBay server can handle 199.609 requests per minute. This value is quite low compared with other web servers such as Google. Likewise, you can take the values for different servers and compare them with other servers to get an idea about the overall performance.

Deviation indicates the deviation from the average. The smaller value of deviation, the better server performance.

Extending the Performance Test to Two Servers Running In Parallel In a Two-node Cluster Environment

Let’s assume your servers are deployed in a cluster environment where the cluster operates with two nodes. Let’s see how you can carry out a performance test against a setup similar to this:

  1. Add Thread Group
  2. Add necessary JMeter Elements
  3. Add Graph Results
  4. Run the test
  5. Obtain and analyze the results

Step 1

This is similar to what I explained above. You can add a Thread Group by following the same steps. After adding the Thread Group, configure the properties as shown below.

Step 2

Now, we need to add two HTTP Requests to send requests simultaneously to two nodes. There, you can follow the steps that I have explained above to add an HTTP Request.

Under the Methods section, specify the method of the request. As I am sending a POST request, I have changed it for the type POST. Then, under the Path section specify the URL of the server including the IP address and the port. An example is shown below. You need to add two HTTP Requests including the same configs other than the server URLs. When two servers are running on a cluster, the URLs for the two servers will be different. Therefore, when you are adding the second HTTP Request, specify the URL relevant to the second node.

Step 3, Step 4, Step 5 will be similar to the ones explained above. Therefore you can just follow the same actions.

Summing Up

In this article, we learned how to carry out a performance test of a web server with a single node and how to extend the test to a two-node cluster using Apache JMeter. We also discussed how we can analyze and compare the results with those of other servers.