Benchmark

    The operation of depends on the operating environment of Erlang/OTP 21.2 and above version. The installation process is skipped. For details, please refer to the online installation tutorials.

    After the Erlang environment is installed, download the latest code of emqtt-bench and compile it:

    After the compilation, an executable script named emqtt_bench will be generated in the current directory. Execute the following command to confirm that it can be used normally:

    1. ./emqtt_bench
    2. Usage: emqtt_bench pub | sub | conn [--help]

    The output of the above content proves that emqtt_bench has been correctly installed on the host.

    There are three subcommands of emqtt_bench:

    1. pub: used to create a large number of clients to perform the operation of publishing messages.
    2. sub: Used to create a large number of clients to subscribe to topics and receive messages.

    When executing ./emqtt_bench pub --help, you will get the available parameter output.

    For example, we start 10 connections and send 100 Qos0 messages to the topic t every second, where the size of each message payload is16 bytes:

    1. ./emqtt_bench pub -t t -h emqx-server -s 16 -q 0 -c 10 -I 10

    Subscribe

    Execute ./emqtt_bench sub --help to get all available parameters of this subcommand. Their explanations have been included in the table above and are omitted here.

    For example, we start 500 connections, and each subscribes to the t topic with Qos0:

    1. ./emqtt_bench sub -t t -h emqx-server -c 500

    Connect

    For example, we start 1000 connections:

    1. ./emqtt_bench conn -h emqx-server -c 1000

    emqtt_bench supports establishing a secure SSL connection and performing tests.

    One-way certificate:

    Two-way certificate:

    1. ./emqtt_bench sub -c 100 -i 10 -t bench/%i -p 8883 --certfile path/to/client-cert.pem --keyfile path/to/client-key.pem
    2. ./emqtt_bench pub -c 100 -i 10 -t bench/%i -s 256 -p 8883 --certfile path/to/client-cert.pem --keyfile path/to/client-key.pem

    Scenario description

    We verify the use of the tool in 2 most typical scenarios:

    1. Connections: Use emqtt_bench to create millions of connections to EMQX Broker.
    2. Throughput: Use emqtt_bench to create 10W / s Qos0 message throughput in EMQX Broker.

    Device and deployment topology

    A total of three 8C16G servers need to be prepared, one for EMQX Broker and two for client presses:

    • System: CentOS Linux release 7.7.1908 (Core)

    • CPU: Intel Xeon Processor (Skylake) Main frequency: 2693.670 MHZ

    • Server: emqx-centos7-v4.0.2.zip

      • Each press is configured with 10 network cards, which are used to establish a large number of MQTT client connections in the connection test

    The topology structure is as follows:

    1. +-----------------------+
    2. | bench1: 192.168.0.100 | ------- +--------------------------+
    3. +-----------------------+ \-----> | EMQX Broker |
    4. +-----------------------+ /-----> | 192.168.0.99 |
    5. +-----------------------+

    Both the client’s press and the server’s machine need to perform system parameter tuning, refer to Tuning guide.

    Connection test

    After performing system tuning, start the server:

    1. ./bin/emqx start

    Then start 50 thousand connections on each network card on , which is a total of 50w connections:

    1. ./emqtt_bench -h 192.168.0.99 -c 50000 --ifaddr 192.168.0.100
    2. ./emqtt_bench -h 192.168.0.99 -c 50000 --ifaddr 192.168.0.101
    3. ./emqtt_bench -h 192.168.0.99 -c 50000 --ifaddr 192.168.0.102
    4. ./emqtt_bench -h 192.168.0.99 -c 50000 --ifaddr 192.168.0.103
    5. ./emqtt_bench -h 192.168.0.99 -c 50000 --ifaddr 192.168.0.104
    6. ./emqtt_bench -h 192.168.0.99 -c 50000 --ifaddr 192.168.0.105
    7. ./emqtt_bench -h 192.168.0.99 -c 50000 --ifaddr 192.168.0.106
    8. ./emqtt_bench -h 192.168.0.99 -c 50000 --ifaddr 192.168.0.107
    9. ./emqtt_bench -h 192.168.0.99 -c 50000 --ifaddr 192.168.0.108
    10. ./emqtt_bench -h 192.168.0.99 -c 50000 --ifaddr 192.168.0.109

    Perform the same operation on bench2.

    After all connections are established, execute ./bin/emqx_ctl listeners and find the following content to view the information about the number of connections in EMQX Broker:

    Throughput test

    Similarly, first start the server:

    1. ./bin/emqx start

    Start 500 subscription clients in bench1:

    1. ./emqtt_bench sub -t t -h 192.168.0.99 -c 500

    Then start 20 publishers on bench2 and publish 10 messages per second:

    1. ./emqtt_bench pub -t t -h 192.168.0.99 -c 20 -I 100