For project reason I have to measure the performance of OData service being accessed parallelly. And I plan to use the open source tool JMeter to generate a huge number of request in parallel and measure the average response time. Since I am a beginner for JMeter, I write down what I have learned into this blog. I will continue to explorer the advanced feature of JMeter in my daily work.

A team in our company developed an OData service. Now I received a task to test the performance index of this service in the scenario of high concurrent access, such as the average response time of each request after 50,000 requests arrived at the same time. Therefore, I chose jMeter, a useful tool, to simulate high concurrent requests.

  1. Download JMeter from its official website:

jmeter.apache.org/

Go to the installation folder, add the following text in file \bin\user.properties:

httpclient4.retrycount=1

hc.parameters.file=hc.parameters

  1. Create a new test plan for example Customer_Query_OData_test, and right click on it and create a thread group from context menu.

    Create a new test plan and create a thread group based on it:

Below configuration means I would like to generate three request in parallel via three threads, each thread is executed only once. And there is no delay during the spawn of each threads ( Ramp-Up Period = 0 )

The following Settings mean that I want to create three concurrent requests, each implemented by a thread, and each thread only executes once. The delay after each thread is spawned is 0 seconds, meaning that the main thread creates three threads at the same time.

Create a new HTTP request and maintain the following Settings:

Create a new Http Request and maintain the following settings: (1) Protocol: https (2) Server name: (3) Http request method: GET (4) Http path: / SAP/c4c/odata/v1 / c4codata AccountCollection / – this is the relative path to the odata service (5) Use KeepAlive: Do NOT select this checkbox

In Parameter TAB, maintain query option $search with value ‘Wang’

This means that each concurrent request initiates an OData query with my name Wang

Switch to Advanced tab, choose “HttpClient4” from drop down list for Implementation, and maintain proxy server name and port number.

Maintain proxy server information in the following location, if any.

  1. Create a new HTTP Header Manager and specify the basic authentication header field and value.

Maintain the credential accessing the Odata service in the HTTP Header Manager. Because the OData service we developed supports Basic Authentication in a serious way, I maintain the Authentication information in the HTTP header field here.

  1. Create a listener for the test plan. In my test I simply choose the most simple one: View Results in Table.

Create a listener to display test results. I use the built-in Listener of jMeter. The Listener is of the Table type, which displays indicators of high concurrent requests and responses in a Table form.

Once done, start the test:

With everything in place, click on the green triangle to start the test:

After the test is finished, double click on View Result Listener and the response time for each request and the average response time is displayed there:

After the test, double-click the Table Result Listener we created earlier, and the performance metrics for my three concurrent requests are displayed. You can see that of the three requests, the fastest took 5.1 seconds and the slowest 6.9 seconds

Of course, jMeter also supports command-line usage:

Or you can use command line to achieve the same:

-n: use non-GUI mode

-t: specify which test plan you want to run

-l: specify the path of output result file

To verify that the data collected by jMeter is correct and reliable, I also took the time to write a Java program to generate concurrent requests using the JDK’s own thread pool, and the test results were consistent with jMeter. And I have written a simple Java application to generate parallel request via multiple thread and the result measured in Java program is consistent with the one got from JMeter. The source code could be found from my github:

My Java program is on my Github: github.com/i042416/Jav…

How to generate random query for each thread in JMeter

So far, my three concurrent requests for search parameters have all been hard-coded Wang, which doesn’t quite fit the actual scenario. Is there a way to generate random search strings that are more realistic?

Suppose we would like each thread in JMeter to generate different customer query via OData with the format JerryTestCustomer_<1~100>, we can simply create a new user parameter:

Add->Pre Processors ->User Parameters:

Parameter name: UUID Parameter value: Use JMeter predefined function __Random to generate random number. Use jMeter’s built-in random number generator function __Random.

So the value of the final parameter uuid is ${__Random(1,100)}, which means a random positive integer between 1 and 100 is generated

and in http request, just specify reference to this variable via ${uuid}:

In HTTP requests, random search strings are constructed using the fixed prefix JerryTestCustomer_ with random arguments:

So that in the end each thread will issue different query to OData service end point.

From the Table Result listener, you can see that this time, indeed, each search initiated by the request uses a different string.

I hope this article introduces some useful tips for using jMeter.

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: