https://www.cnblogs.com/lingyejun/p/7898873.html
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>
硬件配置 | tsung压测客户端配置:i7 8核 32G | ||
---|---|---|---|
mqtt服务器端:i5 4核 6G 128SSD | |||
测试场景 | 最大连接数 | 峰值时客户端情况 | 峰值时服务器端情况 |
c4cpu+s5g+4gmqtt+nolog | 197626 | 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,一共两台机器一起压。
单台最大峰值时的连接数截图:
两台最大峰值时的连接数截图: