http://www.javashuo.com/article/p-fczbczhz-q.htmlhtml
Tsung壓測時總鏈接數 = 本機可用IP地址數量×本機可用端口的數量×遠程服務器可訪問IP地址數量×遠程服務器可訪問端口數量。 yum install -y gcc gcc-c++ make libX11 xauth yum install -y cairo-devel pango-devel freetype-devel gd-devel yum install -y ncurses-devel openssl-devel unixODBC-devel wxWidgets-devel wxGTK3-docs mesa-libGL-devel wget http://erlang.org/download/otp_src_20.0.tar.gz wget https://www.cpan.org/modules/by-module/Template/Template-Toolkit-2.26.tar.gz wget http://tsung.erlang-projects.org/dist/tsung-1.7.0.tar.gz tar zxf otp_src_20.0.tar.gz cd otp_src_20.0 ./configure --prefix=/usr/local/erlang --without-javac make -j 2 make install tar zxf gnuplot-4.4.2.tar.gz cd gnuplot-4.4.2 ./configure make -j 2 make install export PATH=$PATH:/usr/local/erlang/bin/ tar zxf tsung-1.7.0.tar.gz cd tsung-1.7.0 ./configure --prefix=/usr/local/tsung
<?xml version="1.0"?> <!DOCTYPE tsung SYSTEM "/usr/local/tsung/share/tsung/tsung-1.0.dtd"> <tsung loglevel="debug" version="1.0"> <clients> <client host="bogon" maxusers="100000" cpu="1"> <ip value="192.168.1.152"></ip> <ip value="192.168.1.153"></ip> <ip value="192.168.1.154"></ip> <ip value="192.168.1.155"></ip> </client> </clients> <servers> <server host="192.168.1.110" port="61613" type="tcp" /> </servers> <load> <user session="mqtt_subscriber" start_time="30" unit="second"></user> <arrivalphase phase="1" duration="60" unit="second"> <users maxnumber="100000" arrivalrate="5000" unit="second"/> </arrivalphase> </load> <sessions> <session name="mqtt_publisher" probability="100" type="ts_mqtt"> <request> <mqtt type="connect" clean_start="true" keepalive="10" username="admin" password="password" will_topic="phihome/test" will_qos="0" will_msg="will_msg" will_retain="false"></mqtt> </request> <for from="1" to="10" incr="1" var="loops"> <request subst="true"> <mqtt type="publish" topic="phihome/test" qos="1" retained="true">test_message</mqtt> </request> </for> <request> <mqtt type="disconnect"></mqtt> </request> </session> <session name="mqtt_subscriber" probability="0" type="ts_mqtt"> <request> <mqtt type="connect" clean_start="true" keepalive="10"></mqtt> </request> <request subst="true"> <mqtt type="subscribe" topic="test_topic" qos="1"></mqtt> </request> <request> <!-- wait for 60s --> <mqtt type="waitForMessages" timeout="60"></mqtt> </request> <request subst="true"> <mqtt type="unsubscribe" topic="test_topic"></mqtt> </request> <request> <mqtt type="disconnect"></mqtt> </request> </session> </sessions> </tsung>
硬件配置java |
tsung壓測客戶端配置:i7 8核 32Gc++ |
||
mqtt服務器端:i5 4核 6G 128SSDweb |
|||
測試場景服務器 |
最大鏈接數session |
峯值時客戶端狀況tcp |
峯值時服務器端狀況oop |
c4cpu+s5g+4gmqtt+nolog測試 |
197626ui |
cpu充足,內存充足。 |
cpu充足,內存有剩餘。 |
c6cpu+s6g+4gmqtt+nolog |
281477 |
cpu充足,內存充足。 |
cpu充足,內存有剩餘。 |
c6cpu+s6g+2gmqtt+log |
287524 |
cpu充足,內存充足。 |
cpu充足,內存有剩餘。 |
c6cpu+s6g+4gmqtt+log |
283365 |
cpu充足,內存充足。 |
cpu充足,內存有剩餘。 |
上圖測試場景術語介紹: |
|
c4cpu+s5g+4gmqtt+nolog |
壓測客戶端使用了4個cpu進行壓測,mqtt服務器端爲5g內存,進程啓動內存爲4g,啓動時關閉了日誌輸出。 |
c6cpu+s6g+4gmqtt+nolog |
壓測客戶端使用了6個cpu進行壓測,mqtt服務器端爲6g內存,進程啓動內存爲4g,啓動時關閉了日誌輸出。 |
c6cpu+s6g+2gmqtt+log |
壓測客戶端使用了6個cpu進行壓測,mqtt服務器端爲6g內存,進程啓動內存爲2g,啓動時開啓了日誌輸出。 |
c6cpu+s6g+4gmqtt+log |
壓測客戶端使用了6個cpu進行壓測,mqtt服務器端爲6g內存,進程啓動內存爲4g,啓動時開啓了日誌輸出。 |
注:單臺Tsung壓測官網純淨版mosquitto(單臺Broker),峯值時鏈接數爲197626,後續有追加了另一臺tsung,一共兩臺機器一塊兒壓。
單臺最大峯值時的鏈接數截圖:
兩臺最大峯值時的鏈接數截圖: