Rabbitmq性能測試


1.安裝JAVA環境

先安裝openjdk:

sudo apt-get install openjdk-7-jre
sudo apt-get install openjdk-7-jdk

安裝完成后,用gedit文本編輯器在/etc/profile中添加環境變量:

sudo gedit /etc/profile

在打開的/etc/profile文件末尾添加下面幾行:

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=${JAVA_HOME}/jre 
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib 
export PATH=${JAVA_HOME}/bin:$PATH

最后執行以下命令讓修改生效:

source /etc/profile

2.RabbitMQ性能測試工具​​​​

1)介紹

RabbitMQ有一個測試吞吐量的性能測試工具PerfTest。它是基於Java開發的客戶端。可以配置為模擬基本和高級兩種負載。源碼下載地址:https://bintray.com/rabbitmq/java-tools/perf-test。
2)下載PerfTest 的源碼或者可執行jar包

https://github.com/rabbitmq/rabbitmq-perf-test/releases

https://bintray.com/rabbitmq/java-tools/perf-test

解壓之后運行

// 查看幫助
bin/runjava com.rabbitmq.perf.PerfTest --help

./runjava com.rabbitmq.perf.PerfTest -h amqp://user:pass@192.168.0.1:5672 -e xxx_exchange -k xxx_route -s 50 -x 2 -y 0 --body-content-type application/json -t topic -p -z 5

參數說明:
-h 這個是uri,需要是rabbitmq uri

-s 50個字節的消息,打開queue里實際上類似:

-t 默認exchange是direct,如果不是必須指定-t否則出錯。

-p是聲明queue是durable持久化的

3)並發測試

// 1個生產者,兩個消費者,加-a 是自動確認,去掉a后是手動確認
bin/runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "throughput-test-1" -a --id "test 1"  

// 使用持久隊列和持久消息
bin/runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "throughput-test-5" --id "test-5" -f persistent

選項說明:
-x,--producers producer count(生產者數量)
-y,--consumers consumer count(消費者數量)
-u,--queue queue name(隊列名稱)
-a,--autoack auto ack,客戶端在處理完messages之后會給服務端返回一個ack確認信息,服務端在收到該ack信息之后才會把messages刪除;
-d,--id test ID(本次測試的編號,身份標識)

相關鏈接

https://www.cnblogs.com/saryli/p/9713156.html
https://www.rabbitmq.com/java-tools.html
https://www.ctolib.com/jc3wish-RabbitMQTest.html
https://github.com/rabbitmq/rabbitmq-perf-test/releases/tag/v2.14.0
https://github.com/jc3wish/RabbitMQTest
https://www.codeprj.com/blog/a40c231.html
https://www.freesion.com/article/2303208238/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM