Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use jMeter to test the high concurrency performance of an OData service

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to use jMeter to test the high concurrent performance of an OData service, which has certain reference value. Interested friends can refer to it. I hope you can learn a lot after reading this article.

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 developed an OData service, and now I've been asked to test the service's performance in highly concurrent access scenarios, such as the average response time per request after 50, 000 requests arrive at the same time, so I chose jMeter, a useful tool to simulate highly concurrent requests.

Download JMeter from its official website:

Http://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

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 through a thread, and each thread executes only once. The delay after each thread is derived is 0 seconds, which means 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 of the OData service

(5) Use KeepAlive: do NOT select this checkbox-remember to leave this tick off

In Parameter tab, maintain query option $search with value 'Wang'

This means that each concurrent request launches an OData query at the same time, and the parameter is my name Wang.

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

If there is an agent, maintain the proxy server information in the following figure.

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

Maintain the credential that accesses the Odata service in HTTP Header Manager. Because the OData service we developed supports the serious approach of Basic Authentication, I maintain the Authentication information in the HTTP header field here.

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

The main purpose of creating a listener is, of course, to display test results. I use the Listener,Table type that comes with jMeter, which shows the metrics of highly concurrent requests and responses in tabular form.

Once done, start the test:

When everything is ready, 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 testing, 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 request 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

In order to verify whether the data collected by jMeter is correct and reliable, I also took the time to write a Java program that uses the thread pool that comes with JDK to generate concurrent requests, and the test results are 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:

Https://github.com/i042416/JavaTwoPlusTwoEquals5/tree/master/src/odata

How to generate random query for each thread in JMeter

So far, the search parameters for my three concurrent requests are all hard-coded Wang, which doesn't quite match the actual scenario. Is there any way to generate some random search strings that are closer to the real usage scenario?

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

Of course there is a way: right-click menu, Add- > Pre Processors (preprocessor)-> User Parameters:

Parameter name Parameter name, which is taken as uuid

Parameter value Parameter value: use JMeter predefined function _ Random to generate random number.

Use the random number included with jMeter to generate the function _ _ Random.

So the value of the final parameter uuid is ${_ _ Random (1100)}, which means to generate a random positive integer from 1 to 100.

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

In a http request, a random search string is constructed with a fixed prefix JerryTestCustomer_ plus random parameters:

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

Through Table Result listener, you can observe that the search initiated by each request does use a different string this time.

Thank you for reading this article carefully. I hope the article "how to use jMeter to test the high concurrency performance of an OData service" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report