Emqx 压力测试
文章目录
官方说明
非常简洁的说明了安装步骤:
git clone https://github.com/emqx/emqtt-bench
cd emqtt-bench
make
当然,如果想直接使用已经编译好的二进制文件,官方也有提供:
如果是自己编译时,需要安装 erlang 环境。
erlang 环境安装(编译)
安装包下载地址:http://erlang.org/download/
wget http://erlang.org/download/otp_src_18.3.tar.gz
tar zxvf otp_src_18.tar.gz
cd otp_src_18.3/
./configure --prefix=/home/erlang(指定安装目录)
make
make install
执行成功后,配置环境变量:
export PATH=$PATH:/home/erlang/bin
然后执行 erl 验证是否安装成功
erl
Erlang/OTP 25 [erts-13.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]
Eshell V13.0.2 (abort with ^G)
erlang 环境安装(MAC)
通过 brew 安装:
brew install erlang
安装成功后执行:
$ erl -v
Erlang/OTP 25 [erts-13.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]
Eshell V13.0.2 (abort with ^G)
1>
看到如上信息时,则说明 erlang 已经安装成功了,此时再回到 emqtt-bench 目录执行 make,但是你会发现依然会有错误:
=ERROR REPORT==== 7-Jul-2022::11:18:44.597881 ===
beam/beam_load.c(551): Error loading function rebar3:parse_args/1: op put_tuple u x:
please re-compile this module with an Erlang/OTP 25 compiler
escript: exception error: undefined function rebar3:main/1
in function escript:run/2 (escript.erl, line 750)
in call from escript:start/1 (escript.erl, line 277)
in call from init:start_em/1
in call from init:do_boot/3
make: *** [unlock] Error 127
从错误日志上看应该 rebar3 出现问题了,从 emqtt_bench 目录下的 rebar3 是有问题的,那怎么办? 那自然想到的是重新安装。
安装 rebar3
github
brew install rebar3
安装成功后:
$ rebar3 -v
rebar 3.19.0 on Erlang/OTP 25 Erts 13.0.2
这个时候发现 rebar3 已经安装成功了,这个时候再回到 emqtt_bench 执行 make,然而,你会发现还是会出现 rebar3 的错误?
WHY?
我们不是已经安装了 rebar3 了吗,也确认确实已经安装成功了,那问题到底出现在哪里?
这个时候我们冷静下来再思考思考,会不会当前编译时使用的 rebar3 并不是我们安装的?那我们打开 Makefile 看看。
REBAR = $(CURDIR)/rebar3
REBAR_VERSION = 3.14.3-emqx-7
...
这个时候看到了,rebar3 使用的是当前路径下 rebar3 ,并非我们刚刚安装的,而且从一开始的错误日志就知道,当前目录下的 rebar3 文件是有问题的,那我们直接改下 Makefile 文件:
REBAR = rebar3
REBAR_VERSION = 3.14.3-emqx-7
...
这样就会直接使用环境变量里面的 rebar3 了,此时我们再执行 make 试试:
rebar3 unlock
rebar3 compile
===> Verifying dependencies...
===> Fetching emqtt (from {git,"https://github.com/emqx/emqtt",{tag,"1.6.0"}})
===> Fetching getopt v1.0.1
===> Fetching quicer (from {git,"https://github.com/emqx/quic.git",{tag,"0.0.14"}})
===> Fetching cowlib v2.11.0
===> Skipping getopt v1.0.2 as an app of the same name has already been fetched
===> Fetching gun (from {git,"https://github.com/emqx/gun",{tag,"1.3.4"}})
===> Fetching snabbkaffe v1.0.1
执行成功后,你就会发现在 emqtt-bench/_build/emqtt_bench 下生成 emqx 压力测试工具
emqx 压力测试
./bin/emqtt_bench conn -h [host] -p [port] -u [user] -P [password] -S true -c 4096
详细说明
进阶-系统参数调优
https://www.emqx.io/docs/en/v5.0/deploy/tune.html#linux-kernel-tuning
文章作者 Brook
上次更新 2022-07-07