Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is HiveMQ?

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what HiveMQ is, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!

A brief introduction

HiveMQ is an enterprise-class MQTT Broker that provides enterprise-class services with high performance, high availability, high scalability and high security.

It is implemented in pure Java.

Official website address: http://www.hivemq.com

Based on the above description, we analyze its source code based on its high performance, high availability, high scalability and high security.

Note: the source code of this article is based on the source code of HiveMQ 3.1.2.

Topological graph

Single

Multiple clients connect directly to Broker. Cluster

Multiple clients connect with Load Balancer, and Load Balancer does load balancing and distributes the connection to each Broker. Multiple Broker compose Cluster, and JGroup carries on cluster communication. Multiple Broker are made up of virtual nodes of consistent hash ring for master backup of data in the cluster to achieve high availability. HiveMQ provides a variety of cluster Discovery to achieve cluster discovery in different networking scenarios.

Architecture diagram

Handlers is implemented by Netty ChannelHandlerAdapter. Dealing with SSL; processing MQTT protocol codec; processing monitoring data collection; dealing with traffic restrictions; extension point callback trigger and other client long links.

SPI is extended by HiveMQ for secondary development on the HiveMQ Broker side, providing a variety of extension points-Callback, Cache, Scheduler, Authentication, Authorization,-Configuration, etc., as well as various asynchronous / synchronous interfaces Service. So that developers can develop their own business based on HiveMQ

Plugins is based on the extension point provided by SPI. According to the Plugin development requirements of HiveMQ, the official registration of Plugin,HiveMQ which belongs to the customer also provides us with some basic plug-ins and examples of various plug-ins.

ClusterServices is a pile of Service that handles cluster connections, data backup, data exchange, node status, consistency has virtual nodes, etc.

Persistences is the storage of processing messages and the data storage / synchronization between Cluster nodes.

LocalPersistences is the information store that processes messages at the current node.

Use of open source framework

Use Guice to do DI

Using Netty 4 as the Network Framework

Using JGroups to do Cluster Communication between Cluster Node

Using Exodus for persistent Storage of Broker Information Files

Use Dropwizard Metrics to do Broker statistics and monitoring

Serialization / deserialization using Kryo

Use Jetty as a broker-side servlet container

Using Resteasy as a broker-side restfull Framework

Using Quartz/ to schedule Broker tasks

There are other frameworks used that are not listed one by one.

Official tool: https://www.hivemq.com/developers/community/

Authentication: https://www.hivemq.com/docs/4.2/extensions/introduction.html (seems to provide an authenticator for each grid?)

Hardware configuration and performance optimization: https://www.hivemq.com/docs/4.2/hivemq/system-requirements.html( includes file handle resizing and TCP buffer resizing)

Hivemq extension development library: https://github.com/hivemq?q=extension&type=&language=java( provides a variety of api, which feels like you can do a lot of things.

Extend the development library api: https://www.hivemq.com/docs/4.2/extensions-javadoc/index.html

The hivemq extender HTTP provides a readiness check, which means that the service can detect whether the HiveMQ instance is offline: https://github.com/hivemq/hivemq-heartbeat-extension

Hivemq benchmark test

Base 1000W connection / 40 nodes = 25W/node

Message Rate for Publisher

TestMsg/secQoS 04.00QoS 12.00

Detailed performance test reports of 
 can be downloaded from the PDF document on the official website.

Machine:

TestMsg/secInstance Typec4.2xlargeRAM15GiB (~ 16GB) vCPU8Physical ProcessorIntel Xeon E5-2666 v3Clock Speed (GHz) 2.9Dedicated EBS Bandwidth (Mbps) 1000Operating SystemVanilla Amazon Linux ami-b73b63a0

Conclusion:

Hivemq client calls charge 8 minutes and 47 seconds to connect 1000W connections to hivemq, an average of 500connections per second

CPU:38% → 25%

Memory: 6.97-7.6

Quick Results: Connect & Subscribe Test-10000000 MQTT clients

HiveMQ 3.3.0

40 node Cluster

Connect Duration: Connect Speed (avg):

CPU Memory

Subscribe Duration: Subscribe Speed (avg):

CPU Memory

8 min 47 sec 19011 connects/sec 30% 5.07 GB

4 min 31 sec 36765 subscribes/sec 38% 6.97 GB

Tests show that HiveMQ can process an average of 1.74 million messages per second (1739876 milliseconds per second) and 167000 messages per second (166925 milliseconds per second). During the 30-minute test period, there were a total of 3.13 billion messages (3131776800 msg) outgoing messages and 300 million msg (300465888 msg) incoming messages.

When looking at the system bandwidth, HiveMQ averages 389.78 megabytes (408711565 bytes per second) out and 327.84 MB / second (343762614 bytes per second) incoming.

During the test execution, the average CPU utilization was 64.72%, and the memory was 11.33 GB (12164655331 bytes).

QoS 0 test shows that

HiveMQ has a strong throughput capacity in large clusters, which can give full play to its advantages in horizontal scale. HiveMQ for clients with 10 million concurrent connections achieves a constant throughput of 1.7 million outgoing messages per second, with an average CPU load of no more than 64 per cent. To make numbers easier to grasp, let's compare them with some large Internet applications, a good example of which is WhatsApp. In 2014, WhatsApp tweeted that they had received 64 billion messages (20 billion incoming messages and 44 billion outgoing messages) in one day. Comparing a total of 64 billion messages with the number we got in the test, we had 3432242688 messages every 30 minutes when adding incoming and outgoing traffic. A total of 164.75 billion messages were added per day (164747649024 messages). The HiveMQ cluster can easily handle 2.5 times the amount of messages sent through the entire WhatsApp infrastructure every day! When looking at performance and load metrics, it is clear that HiveMQ not only provides high throughput, but also maintains a controlled and stable state with 64% CPU and 73% memory usage.

The QoS 1 test shows that

HiveMQ can process an average of 780000 messages per second (779576 msg / sec) and 780000 messages per second (779.577 msg / sec). During the 30-minute test period, a total of 1.4 billion messages (1403237449 msg) came out and 1.4 billion messages (1403237882 msg) came in.

When looking at system bandwidth, HiveMQ averages 279.44 megabytes per second (293010785 bytes per second) and 220.24 MB per second (230935379 bytes per second).

HiveMQ can handle 10.000.000 connections on hardware and has excellent, stable throughput, with 1.7 million outgoing messages (QoS 0 test) and 780 msg / sec in both incoming and outgoing directions (QoS 1 test). HiveMQ can easily scale horizontally to the middle two digits of the cluster node HiveMQ can handle large fan-out situations with high magnification. Throughout the test time frame, throughput remains constant and stable, and message rates vary with cluster size and the number of CPU. HiveMQ has the ability to scale horizontally, making it ideal for small and large deployments. It is the most scalable MQTT agent with excellent performance even though it provides QoS 1 assurance.

Hivemq configuration item operating system

Production: Linux is the only operating system currently supported in the production environment. CentOS7 or other RHEL-based distributions are recommended.

Minimum hardware requirements

At least 4GB RAM

4 or more CPU

100GB or more free disk space.

Environment

Production: OpenJDK JRE 11 or later is required.

Linux configuration optimization

You can optimize your Linux configuration in several ways:

Increase the limit on opening files

If you are running HiveMQ on the Linux operating system, be sure to allow the HiveMQ process to open a sufficient number of files. To adjust the limit, add the following lines to the / etc/security/limits.conf file:

Hivemq hard nofile 1000000

Hivemq soft nofile 1000000

Root hard nofile 1000000

Root soft nofile 1000000

Adjust TCP settin

On systems with many connections, it may be necessary to adjust the TCP configuration and have the system open more sockets. To make these adjustments, add the following line to the / etc/sysctl.conf file:

# this causes the kernel to actively send RST packets when the service is overloaded.

Net.ipv4.tcp_fin_timeout = 30

# the largest file handle that can be allocated.

Fs.file-MAX = 5097152

# enable quick recycling of waiting sockets.

Net.ipv4.tcp_tw_recycle = 1

# from a protocol perspective, the waiting socket is allowed to be reused for a new connection in a secure situation.

Net.ipv4.tcp_tw_reuse = 1

# the default size of the receive buffer is used by the socket.

Net.core.rmem_default = 524288

# the default size of the send buffer used by the socket.

Net.core.wmem_default = 524288

The maximum size of the received buffer used by # sockets.

Net.core.rmem_max = 67108864

The maximum size of the sent buffer used by # sockets.

Net.core.wmem_max = 67108864

# the size of the receive buffer per TCP connection. (minimum, default, maximum)

Net.ipv4.tcp_rmem = 4096 87380 16777216

# the size of the buffer sent by each TCP connection. (minimum, default, maximum)

Net.ipv4.tcp_wmem = 4096 65536 16777216

To apply the changes, type sysctl-p or restart the system.

The above is all the content of this article "what is HiveMQ?" thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report