如何使用jMeter对某个OData服务进行高并发性能测试

简介: 如何使用jMeter对某个OData服务进行高并发性能测试

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.


我们公司某团队开发了一个OData服务,现在我接到任务,要测试这个服务在高并发访问场景下的性能指标,比如5万个请求同时到来后,每个请求的平均响应时间,因此我选择了jMeter这个好用的工具来模拟高并发请求。

image.png

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.

创建一个新的测试plan,基于其再创建一个线程组:


image.png

image.png

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 )


下列设置意思是我想创建三个并发请求,每个请求通过一个线程实现,每个线程仅仅执行一次。每个线程派生后的延时是0秒,意思是主线程同时创建三个线程。


image.png

创建一个新的HTTP请求,维护下列设置:


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/ - 这就是OData服务的相对路径了

(5) Use KeepAlive: do NOT select this checkbox - 记得这个勾别打上


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


这个意思就是每个并发请求同时发起OData查询,参数为我的名字Wang

image.png

image.png

image.png

当然,jMeter也支持命令行方式使用:

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

image.png

为了检验jMeter采集的数据是否正确可靠,我还花时间写了一个Java程序,用JDK自带的线程池产生并发请求,测试的结果和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:


我的Java程序放在我的github上:

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


image.png

image.png

How to generate random query for each thread in JMeter


到目前为止,我的三个并发请求进行搜索的参数都是硬编码的Wang,这个和实际场景不太符合。有没有办法生成一些随机的搜索字符串,这样更贴近真实使用场景呢?


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:

image.png

image.png

image.png

希望这篇文章介绍的jMeter使用技巧对大家工作有所帮助。

相关实践学习
通过性能测试PTS对云服务器ECS进行规格选择与性能压测
本文为您介绍如何利用性能测试PTS对云服务器ECS进行规格选择与性能压测。
相关文章
|
5月前
|
Cloud Native 测试技术
性能测试小工具 wrk 可以怎么用
性能测试小工具 wrk 可以怎么用
|
7月前
|
XML 前端开发 测试技术
使用 jMeter 对 SAP Spartacus 进行并发性能测试
使用 jMeter 对 SAP Spartacus 进行并发性能测试
73 0
|
3月前
|
JSON 网络协议 Java
使用Jmeter进行功能和性能测试
使用Jmeter进行功能和性能测试
|
10月前
|
网络协议 前端开发 JavaScript
如何使用jmeter进行压测
1.概述 一款工具,功能往往是很多的,细枝末节的地方也很多,实际的测试工作中,绝大多数场景会用到的也就是一些核心功能,根本不需要我们事无巨细的去掌握工具的所有功能。所以本文将用带价最小的方式讲解如何快速上手使用jmeter来进行压测。 JMeter,一款接口测试工具,是Java程序,需要JDK环境,建议使用JDK8或者JDK11。
229 0
|
11月前
|
测试技术
Jmeter性能测试实战
Jmeter性能测试实战
|
Java 测试技术 开发者
Jmeter性能测试|学习笔记
快速学习Jmeter性能测试
83 0
|
监控 测试技术 Python
利用Taurus框架结合Jmeter进行性能测试
利用Taurus框架结合Jmeter进行性能测试
296 0
利用Taurus框架结合Jmeter进行性能测试
|
测试技术 编译器 Python
性能专题:Locust工具实战之创建性能测试
性能专题:Locust工具实战之创建性能测试
180 0
性能专题:Locust工具实战之创建性能测试
|
测试技术 Python
【性能测试系列】Locust - 一款开源的负载测试工具
最近做系统性能调优,发现了一款比较好用的性能测试工具Locust;在此推荐给各位同学。
187 0
【性能测试系列】Locust - 一款开源的负载测试工具
性能测试实战 | 修改 JMeter 源码,定制化聚合压测报告
性能和压力测试是每一个互联网应用程序上线之前都必须检验的测试项目。JMeter 作为目前互联网大厂最流行、最强大的性能测试工具,已经成为测试人员行走江湖的必备利器。 相比传统的压力测试工具(如 LoadRunner),JMeter 最显著的特点就是开源、轻量级、易于维护、便于扩展。 面对变化多端的业务情况,测试开发人员可以基于 JMeter 源码修改和二次开发,快速实现定制化功能,更好的满足业务