The material for this article comes from the speech made by Erlang Solutions engineer Grigory Starinkin at the RabbitMQ Summit 2019 conference. The original content mainly introduces the MQTT message server EMQ X and RabbitMQ and compares the stress test. On this basis, we supplemented it, deeply analyzed the focus of EMQ X and RabbitMQ on the core architecture, and analyzed their different effects on the performance MQTT cluster

MQTT protocol-subscribe and publish

MQTT is a very lightweight subscription and publishing protocol. It is now the most dominant and most widely used transmission protocol in the Internet of Things field. The MQTT protocol requires at least 2 bytes per message (of which only 1 byte is required for the header, and the rest of the bytes can be used as the message payload) to complete the communication. It is specially designed for hardware with limited resources and space and power consumption Build. The main mode is Pub/Sub (publish/subscribe), the client can play two roles, one role is the publisher, after connecting to the server, it will send messages to the server for a specific topic; the other role is the subscriber , You can subscribe to topics of interest to receive the news. Subscribers can also use wildcards to subscribe to topics, so that they can subscribe to multiple different topics at once, and they can also use shared subscriptions for load balancing distribution.

The following picture reveals how the MQTT protocol works:

MQTT协议运作.png

There are many MQTT client SDKs on the market, and there are also many MQTT Broker . EMQ X and RabbitMQ are the two representative open source messaging servers in the Erlang family. Next, we will make an in-depth comparison of them for the MQTT scenario.

EMQ X and RabbitMQ

EMQ X is an open source MQTT message server developed based on the highly concurrent Erlang/OTP language platform, supporting millions of connections, distributed cluster architecture, and publish-subscribe mode. Since open source, EMQ X has been widely used in the global Internet of Things market. On the basis of the open source version, a commercial version and a cloud-hosting version have been successively developed ( https://www.emqx.com/zh/cloud ). EMQ X supports many plug-ins and has powerful expansion capabilities. Users can rely on plug-ins to achieve more functions.

RabbitMQ is an open source message broker software (also known as message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP). The RabbitMQ server is also developed based on the Erlang language, and it can now support the MQTT protocol in the form of plug-in configuration.

It is not difficult to find that they have chosen Erlang as the development language, and they have all used the distributed database management system carried by the Erlang language-Mnesia. Mnesia is suitable for exchanging routing topology and exchanging information between nodes in the cluster.

pressure test

actual performance of the 16131b9f024832 MQTT server is usually used by users as a criterion for judging the quality of a server. Therefore, this evaluation will also focus on the performance test results of these two servers under the stress test.

test tools

MZBench was selected as the tool for this stress test. MZBench ( https://github.com/mzbench/mzbench ) is a testing tool written in Erlang language. It has the following three types of nodes:

  • MZSever: can be used to create scenarios, such as creating a publisher and multiple subscribers. This information will be transmitted to MZBench as a server;
  • MZController: The information generated from the server will be further transmitted here;
  • MZNodes: They will be used as MQTT client to connect to your cluster, as shown in the figure below.

MZBench测试工具.png

This evaluation uses an instance of cloud host M5 large. Each MQTT message server cluster is composed of 3 nodes, and each node is configured with dual cores and 8GB of memory. What needs to be emphasized is that we used exactly the same hardware resources to eliminate variables for EMQ X and RabbitMQ tests. All of these are equipped with a Prometheus node exporter for pushing metrics to Prometheus, and Grafana will perform the final data collection.

testing scenarios

The stress test will have two scenarios, "many-to-one" and "one-to-many".

Many to one

Many devices act as publishers, such as temperature sensors or pressure sensors, sending data to a server. The server then sends these data to a controller (that is, the subscriber) to process the data.

测试场景多对一.png

One to many

A controller acts as a publisher to transmit messages to the server, and the server transmits these messages to multiple devices as subscribers.

测试场景一对多.png

In each scene, the number of "more" parties will gradually rise from 2,000 to 10,000. In each scene, a message with a payload of 256 bytes is sent every second. Such a release will not cause excessive throughput. The purpose of using only 256 bytes of payload is to show how these two servers work and how their cluster mode responds to these scenarios.

Test Results

The left Y-axis refers to CPU usage, and the bottom X-axis refers to changes in the number of clients on the "multiple" side.

Many to one

From the "many to one" result, it can be seen that there is not much difference between EMQ X and RabbitMQ.

多对一测试结果.png

One to many

However, from the results of "one-to-many", RabbitMQ does have a significant gap compared to EMQ X.

一对多测试结果.png
What is the reason for this gap? We will analyze the specific reasons in detail in the next content.

Copyright statement: This article is EMQ original, please indicate the source for reprinting.

Original link: https://www.emqx.com/zh/blog/emqx-or-rabbitmq-part-1

Technical support: If you have any questions about this article or EMQ-related products, you can visit the EMQ Q&A community https://askemq.com . We will reply and support in time.

For more technical dry goods, please pay attention to our public account [EMQ Chinese Community].


EMQX
336 声望438 粉丝

EMQ(杭州映云科技有限公司)是一家开源物联网数据基础设施软件供应商,交付全球领先的开源 MQTT 消息服务器和流处理数据库,提供基于云原生+边缘计算技术的一站式解决方案,实现企业云边端实时数据连接、移动、...