Jmeter 是開源軟件,100%純java應用程序,專門爲負載測試和性能測試。html
Jmeter的特性包括:java
1.負載測試和性能測試許多不一樣的服務器/協議類型:web
2.完整的可移植性和純Javashell
3.多線程框架容許併發線程和同步採樣,針對不一樣的功能和單獨的線程。apache
4.詳細的GUI設計能快速創建測試計劃和調試。緩存
5.緩存式和離線式分析測試結果服務器
6.高度可擴展:網絡
6.1插入取樣器,拓展測試功能;多線程
6.2負載統計能插入計時器併發
6.3數據分析和可視化插件容許很大的可擴展和個性化
6.4函數可用於提供動態輸入一個測試或提供數據操做。
6.5腳本取樣器
網站http://jmeter.apache.org/包含全部所需的信息如何使用JMeter的工具。請參閱文檔菜單和閱讀和理解的開始部分和用戶手 冊。第一個將爲您提供必要的信息下載、安裝和運行JMeter的工具。用戶手冊中你還會找到詳細的信息關於JMeter測試計劃和全部元素可使用在建立 測試計劃。
JMeter測試步驟:
這個簡短的教程解釋如何使用多個系統執行性能測試。在咱們開始以前,有幾件事檢查:
1。全部機器須要安裝Java和JMeter工具部署。
2.關掉防火牆系統
3.全部用戶在同一個子網
4.服務器在同一個子網
5.Jmter能訪問服務器
6.全部系統確保同一個版本的Jmeter,結果準確
一旦你肯定系統準備好了,設置遠程
本教程假設您已經安裝了JMeter全部的系統。JMeter的工做方式是1主控制器啓動測試在多個從系統。
術語:
在咱們開始以前,讓咱們定義條款和保證的定義是明確的:
Master:系統運行Jmeter GUI或非GUI,控制測試
slave:運行的系統jmeter-server,須要從主命令和請求發送到目標系統(s)
Target:系統運行jmeTarget服務器咱們計劃性能測試
步驟:
1.在slave systems上,進入到jmeter/bin目錄,打開jmeter-server.sh
2.定義RMI_HOST_DEF,增長機器的Ip:
RMI_HOST_DEF=-Djava.rmi.server.hostname=172.48.0.115
3.執行jmeter-server
[devops@ssoperf-jmeter-cluster-02 bin]$ ./jmeter-server
服務正常,出現以下提示:
Created remote object: UnicastServerRef [liveRef: [endpoint:[172.48.0.115:37675](local),objID:[2dadf396:14fdafc8a0e:-7fff, 25749104862551184]]]
4.在主系統做爲控制檯,去jmeter / bin目錄並打開jmeter。屬性文件在一個文本編輯器
5.編輯行「remote_hosts = 127.0.0.1」和添加的IP地址。
例如:remote_hosts=172.48.0.115,172.48.0.116,172.48.0.123
6.JMeter腳本建立的(如sso.jmx)。
7.master開始測試:
/jmeter.sh -Djava.rmi.server.hostname=172.48.0.114 -n -GstartPhoneNumber=10000 -Gthreads=40 -Gloops=50 -Glogin_loop=10 -Gvalidate=100 -t sso.jmx -r -l results.csv -X
master控制jmeter服務器,啓動和中止加載,並從服務器手機統計信息。
命令行選項的列表:
-t, --testfile {argument}
the jmeter test(.jmx) file to run containing the test plan
-l, --logfile {argument}
the file to log samples to
-n, --nongui
run JMeter in nongui mode
-J, --jmeterproperty {argument}={value}
Define additional JMeter properties
-G, --globalproperty (argument)[=(value)]
Define Global properties (sent to servers)
e.g. -Gport=123
or -Gglobal.properties
-D, --systemproperty {argument}={value}
Define additional System properties
更多命令在:http://jmeter.apache.org/usermanual/get-started.html#options
debugging:
Once you started the test in the master system console you will see the following text:
Creating summariser <summary>
Created the tree successfully using sso.jmx
Configuring remote engine: 172.48.0.115
Configuring remote engine: 172.48.0.116
Configuring remote engine: 172.48.0.123
Starting remote engines
Starting the test @ Thu Sep 17 19:47:12 HKT 2015 (1442490432475)
Remote engines have been started
Waiting for possible shutdown message on port 4445
On the slaves you will see the following log for test start and stop:
Starting the test on host 172.48.0.115 @ Thu Sep 17 19:47:19 HKT 2015 (1442490439214)
Finished the test on host 172.48.0.115 @ Thu Sep 17 19:47:30 HKT 2015 (1442490441165)
During the test run the master will receive summary information from the slaves regarding the transactions per seconds, latencies and errors.
e.g.
summary + 6803 in 3s = 2293.7/s Avg: 2 Min: 0 Max: 24 Err: 0 (0.00%) Active: 10 Started: 10 Finished: 0
summary + 101500 in 30s = 3381.9/s Avg: 2 Min: 0 Max: 61 Err: 0 (0.00%) Active: 10 Started: 10 Finished: 0
summary = 108303 in 33s = 3284.0/s Avg: 2 Min: 0 Max: 61 Err: 0 (0.00%)
summary + 101100 in 30s = 3370.2/s Avg: 2 Min: 0 Max: 40 Err: 0 (0.00%) Active: 10 Started: 10 Finished: 0
summary = 209403 in 63s = 3325.1/s Avg: 2 Min: 0 Max: 61 Err: 0 (0.00%)
summary + 102900 in 30s = 3430.8/s Avg: 2 Min: 0 Max: 45 Err: 0 (0.00%) Active: 10 Started: 10 Finished: 0
summary = 312303 in 93s = 3359.2/s Avg: 2 Min: 0 Max: 61 Err: 0 (0.00%)
summary + 101800 in 30s = 3393.3/s Avg: 2 Min: 0 Max: 47 Err: 0 (0.00%) Active: 10 Started: 10 Finished: 0
summary = 414103 in 123s = 3367.5/s Avg: 2 Min: 0 Max: 61 Err: 0 (0.00%)
summary + 85897 in 26s = 3334.9/s Avg: 2 Min: 0 Max: 42 Err: 0 (0.00%) Active: 0 Started: 10 Finished: 10
summary = 500000 in 149s = 3361.6/s Avg: 2 Min: 0 Max: 61 Err: 0 (0.00%)
Tidying up remote @ Wed Jul 01 19:43:25 EEST 2015 (1435769005812)
To stop the test just execute:
./stoptest.sh
1。RMI不能溝通跨子網沒有代理,因此也不能jmeter沒有代理。
2。從JMeter發送全部的測試結果控制控制檯,很容易飽和網絡IO。這是一個好主意使用簡單的數據做家保存結果和查看文件以後,一個圖的聽衆。
3 所示。一個JMeter 2-3Ghz CPU上運行客戶端能處理300 - 600線程根據測試的類型。(惟一的例外是web服務)。XML處理CPU密集型和將很快消耗CPU週期。做爲通常規則,以XML爲中心的應用程序的性能 將執行的4到10低於使用二進制協議的應用程序。