Lin Minquan's Blog

Experience technology to change life

How to Stress Test EMQX

In Alibaba Cloud’s Hong Kong region, spin up a few 2-core 4GB preemptible instances (formerly known as spot instances), install Docker, and then use emqx-bench for stress testing.

docker run -it emqx/emqtt-bench:latest conn -c 30000 -i 10 -h IP-ADDRESS -p 1883

docker run: Run a Docker container. -it: Run the container in interactive mode and connect to the terminal. emqx/emqtt-bench:latest: Use the latest version of the emqtt-bench tool image provided by EMQX. conn: Specify the operation type, here it’s connection testing. -c 30000: Specify the number of clients, here simulating 30,000 client connections. -i 10: Indicates the connection interval time for each client is 10 milliseconds. -h IP-ADDRESS: Specify the host address (IP address) of the MQTT server. -p 1883: Specify the port number of the MQTT server.

-i 10 specifies the connection time interval between clients as 10 milliseconds (ms), meaning after simulating one client, it will wait 10 milliseconds before simulating the next client connection. This is very important for distributed stress testing as it prevents creating a large number of connections at once, which could cause instant server overload. This means 100 clients will connect to the server per second.

During the stress testing process, you can monitor server performance indicators such as CPU usage, memory usage, and network bandwidth to determine if the server performance meets expectations.

One server can handle approximately 28,000 connections; beyond that, connection failures will occur.

One EMQX v5.7.1 open-source node can handle approximately 80,000 connections; beyond that, connection failures will occur.

A cluster can have a maximum of 3 nodes, so one cluster can handle up to 240,000 connections. This is much higher than the official data shown below.

EMQX v5.7 feature comparison

Translations


Share