成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

如何使用jMeter對(duì)某個(gè)OData服務(wù)進(jìn)行高并發(fā)性能測(cè)試

qylost / 1677人閱讀

摘要:我們公司某團(tuán)隊(duì)開發(fā)了一個(gè)服務(wù),現(xiàn)在我接到任務(wù),要測(cè)試這個(gè)服務(wù)在高并發(fā)訪問場(chǎng)景下的性能指標(biāo),比如萬個(gè)請(qǐng)求同時(shí)到來后,每個(gè)請(qǐng)求的平均響應(yīng)時(shí)間,因此我選擇了這個(gè)好用的工具來模擬高并發(fā)請(qǐng)求。創(chuàng)建,主要用途當(dāng)然是顯示測(cè)試結(jié)果了。

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.

我們公司某團(tuán)隊(duì)開發(fā)了一個(gè)OData服務(wù),現(xiàn)在我接到任務(wù),要測(cè)試這個(gè)服務(wù)在高并發(fā)訪問場(chǎng)景下的性能指標(biāo),比如5萬個(gè)請(qǐng)求同時(shí)到來后,每個(gè)請(qǐng)求的平均響應(yīng)時(shí)間,因此我選擇了jMeter這個(gè)好用的工具來模擬高并發(fā)請(qǐng)求。

Download JMeter from its official website:

http://jmeter.apache.org/

Go to the installation folder, add the following text in file binuser.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.

創(chuàng)建一個(gè)新的測(cè)試plan,基于其再創(chuàng)建一個(gè)線程組:

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 )

下列設(shè)置意思是我想創(chuàng)建三個(gè)并發(fā)請(qǐng)求,每個(gè)請(qǐng)求通過一個(gè)線程實(shí)現(xiàn),每個(gè)線程僅僅執(zhí)行一次。每個(gè)線程派生后的延時(shí)是0秒,意思是主線程同時(shí)創(chuàng)建三個(gè)線程。

創(chuàng)建一個(gè)新的HTTP請(qǐng)求,維護(hù)下列設(shè)置:

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服務(wù)的相對(duì)路徑了
(5) Use KeepAlive: do NOT select this checkbox - 記得這個(gè)勾別打上

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

這個(gè)意思就是每個(gè)并發(fā)請(qǐng)求同時(shí)發(fā)起OData查詢,參數(shù)為我的名字Wang

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

如果有代理的話,在下圖位置維護(hù)代理服務(wù)器信息。

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

在HTTP Header Manager里維護(hù)訪問這個(gè)Odata服務(wù)的credential。因?yàn)槲覀冮_發(fā)的OData服務(wù)支持Basic Authentication這種認(rèn)真方式,所以我在此處的HTTP header字段里維護(hù)Authentication信息。

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

創(chuàng)建listener,主要用途當(dāng)然是顯示測(cè)試結(jié)果了。我使用的是jMeter自帶的Listener,Table類型的,以表格形式顯示高并發(fā)請(qǐng)求和響應(yīng)的各項(xiàng)指標(biāo)。

Once done, start the test:

一切就緒,點(diǎn)擊這個(gè)綠色的三角形開始測(cè)試:

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:

測(cè)試完畢后,雙擊我們之前創(chuàng)建的Table Result Listener,我這三個(gè)并發(fā)請(qǐng)求的性能指標(biāo)就顯示出來了。可以看到三個(gè)請(qǐng)求中,最快的請(qǐng)求用了5.1秒,最慢的6.9秒

當(dāng)然,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

為了檢驗(yàn)jMeter采集的數(shù)據(jù)是否正確可靠,我還花時(shí)間寫了一個(gè)Java程序,用JDK自帶的線程池產(chǎn)生并發(fā)請(qǐng)求,測(cè)試的結(jié)果和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/Ja...

How to generate random query for each thread in JMeter

到目前為止,我的三個(gè)并發(fā)請(qǐng)求進(jìn)行搜索的參數(shù)都是硬編碼的Wang,這個(gè)和實(shí)際場(chǎng)景不太符合。有沒有辦法生成一些隨機(jī)的搜索字符串,這樣更貼近真實(shí)使用場(chǎng)景呢?

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:

當(dāng)然有辦法:右鍵菜單,Add->Pre Processors(預(yù)處理器)->User Parameters:

參數(shù)名Parameter name,取為uuid
參數(shù)值Parameter value: use JMeter predefined function __Random to generate random number.
使用jMeter自帶的隨機(jī)數(shù)生成函數(shù)__Random。

因此最后參數(shù)uuid的值為${__Random(1,100)},意思是生成1到100內(nèi)的隨機(jī)正整數(shù)

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

在http請(qǐng)求里,用固定的前綴JerryTestCustomer_加上隨機(jī)參數(shù),以此來構(gòu)造隨機(jī)搜索字符串:

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

通過Table Result listener,能觀察到這次確實(shí)每個(gè)請(qǐng)求發(fā)起的搜索都使用了不同的字符串了。

希望這篇文章介紹的jMeter使用技巧對(duì)大家工作有所幫助。

要獲取更多Jerry的原創(chuàng)文章,請(qǐng)關(guān)注公眾號(hào)"汪子熙":

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/72984.html

相關(guān)文章

  • SAP OData編程指南

    摘要:目前被廣泛用于和的眾多應(yīng)用中,以及和一些正在開發(fā)的新一代云產(chǎn)品中。年月時(shí),我和德國(guó)一位負(fù)責(zé)的同事就這個(gè)話題在半小時(shí)的電話會(huì)議里產(chǎn)生了爭(zhēng)執(zhí)。德國(guó)同事看了之后,同意了我的意見。和微信集成系列教程這個(gè)系列教程里,和微信的交互,使用了,使用了。 OData(Open Data Protocol)協(xié)議是一個(gè)開放的工業(yè)標(biāo)準(zhǔn),用于定義RESTFul API的設(shè)計(jì)和使用。我的文章標(biāo)題前加上SAP的前綴...

    X1nFLY 評(píng)論0 收藏0
  • SAP OData編程指南

    摘要:目前被廣泛用于和的眾多應(yīng)用中,以及和一些正在開發(fā)的新一代云產(chǎn)品中。年月時(shí),我和德國(guó)一位負(fù)責(zé)的同事就這個(gè)話題在半小時(shí)的電話會(huì)議里產(chǎn)生了爭(zhēng)執(zhí)。德國(guó)同事看了之后,同意了我的意見。和微信集成系列教程這個(gè)系列教程里,和微信的交互,使用了,使用了。 OData(Open Data Protocol)協(xié)議是一個(gè)開放的工業(yè)標(biāo)準(zhǔn),用于定義RESTFul API的設(shè)計(jì)和使用。我的文章標(biāo)題前加上SAP的前綴...

    wanghui 評(píng)論0 收藏0
  • 使用jMeter構(gòu)造大量并發(fā)HTTP請(qǐng)求進(jìn)行服務(wù)性能測(cè)試

    摘要:比如我開發(fā)好了一個(gè)微服務(wù),想測(cè)試其在大并發(fā)請(qǐng)求下的性能表現(xiàn)如何。比較方便的一個(gè)做法是使用工具來構(gòu)造這些請(qǐng)求。這個(gè)請(qǐng)求的意思是使用請(qǐng)求查詢賬號(hào)名稱為的實(shí)例。維護(hù)完畢之后點(diǎn)執(zhí)行按鈕,會(huì)觀察到個(gè)線程同時(shí)發(fā)出請(qǐng)求,并能看到每個(gè)請(qǐng)求的響應(yīng)時(shí)間。 比如我開發(fā)好了一個(gè)微服務(wù),想測(cè)試其在大并發(fā)請(qǐng)求下的性能表現(xiàn)如何。 比較方便的一個(gè)做法是使用工具jMeter來構(gòu)造這些請(qǐng)求。 創(chuàng)建一個(gè)新的工程: show...

    LeanCloud 評(píng)論0 收藏0
  • 使用jMeter對(duì)基于SAP ID service進(jìn)行Authentication的Restful

    摘要:因?yàn)檫@個(gè)項(xiàng)目最后會(huì)在年月日于上海舉行的云大會(huì)上展示,所以當(dāng)時(shí)完成集成工作后心想,還是得提前測(cè)試一下咱們的在響應(yīng)并發(fā)請(qǐng)求時(shí)的性能做到心里有數(shù)。 這篇文章本來Jerry只在SAP社區(qū)上寫了英文版的,可以通過點(diǎn)擊文末的閱讀原文獲得。后來有兩位做Marketing Cloud開發(fā)的德國(guó)同事,寫郵件詢問關(guān)于文章的更多細(xì)節(jié),聲稱這種方式對(duì)他們自己的API性能測(cè)試很有用,所以我覺得還是值得用中文再寫...

    longmon 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<