NanoMQ: An Ultra-Lightweight and High-Performance MQTT Edge Messaging Platform

The rapid development of the Internet of Things (IoT) and Industrial Internet of Things (IIoT) has raised higher demands for messaging middleware: lightweight, high-performance, low-latency, and easy deployment. NanoMQ is an MQTT message broker that meets these requirements, being a high-performance, lightweight MQTT edge messaging platform based on NNG, particularly suitable for resource-constrained embedded devices and edge computing scenarios.

NanoMQ: An Ultra-Lightweight and High-Performance MQTT Edge Messaging Platform

The Core Architecture of NanoMQ: NNG-Based Actor Model

The core architecture of NanoMQ is based on the Actor model of NNG (NanoMsg), which has been enhanced and optimized. NNG provides high-performance asynchronous I/O and messaging mechanisms, while NanoMQ builds upon this to create an embedded Actor architecture, further enhancing message processing capabilities and system efficiency. This architecture allows NanoMQ to efficiently handle a large number of MQTT connections and messages, maintaining good performance even on resource-constrained embedded devices.

Features and Advantages: Lightweight, Efficient, Highly Compatible

NanoMQ has numerous advantages that make it an ideal MQTT message broker for edge computing scenarios:

  • Lightweight: The code of NanoMQ is concise and resource-efficient, making it very suitable for deployment on resource-constrained embedded devices.
  • High Performance: Based on NNG’s asynchronous I/O and Actor model, NanoMQ features extremely low latency and high throughput.
  • High Compatibility: Fully based on POSIX standards, it has good cross-platform compatibility, allowing easy deployment on various operating systems and hardware platforms.
  • Pure C Implementation: Written in pure C, it has high portability and is easy to integrate into existing embedded systems.
  • Multithreading Support: Supports multithreading, allowing full utilization of multi-core processor performance.
  • MQTT Protocol Support: Fully supports MQTT V3.1.1/3.1 and MQTT V5.0 protocols.

Installation and Deployment: Flexible and Convenient

NanoMQ offers various installation and deployment methods, allowing users to choose based on their needs:

  • Docker Deployment: NanoMQ can be quickly deployed using Docker containers, simplifying the installation and configuration process. A simple Docker command is all that is needed to start NanoMQ:
docker run -d --name nanomq -p 1883:1883 -p 8083:8083 -p 8883:8883 emqx/nanomq:latest
  • Source Compilation: For more fine-grained control, NanoMQ can be compiled from source. This requires a C99 compatible compiler and CMake. It is recommended to use the Ninja build system, which can significantly speed up the compilation process:
git clone https://github.com/emqx/nanomq.git
cd nanomq
git submodule update --init --recursive
mkdir build && cd build
cmake -G Ninja ..
ninja

Source compilation also supports various customization options, such as enabling QUIC, TLS, SQLite, and more.

Build Options: Custom Configuration

NanoMQ provides rich build options, allowing users to customize the features and characteristics of NanoMQ according to their needs:

  • <span>-DNNG_ENABLE_QUIC=ON</span>: Enable QUIC bridging functionality.
  • <span>-DNNG_ENABLE_TLS=ON</span>: Enable TLS support (requires mbedTLS to be installed beforehand).
  • <span>-DBUILD_CLIENT=OFF</span>: Disable the NanoMQ tool client suite.
  • • Other options include building static libraries, dynamic libraries, enabling debug information, etc.

Application Scenarios: An Ideal Choice for Edge Computing

The lightweight and high-performance features of NanoMQ make it an ideal choice for edge computing scenarios. It can be applied in various IoT applications, such as:

  • Industrial Automation: Monitoring the operational status of industrial equipment, collecting and processing sensor data.
  • Smart Home: Controlling smart appliances to achieve home automation.
  • Vehicle Networking: Enabling communication between vehicles and between vehicles and infrastructure.
  • Other Edge Computing Scenarios: Any scenario requiring a lightweight, high-performance MQTT message broker.

Conclusion

NanoMQ is a powerful, lightweight, and high-performance MQTT edge messaging platform built on NNG and employing an efficient Actor model architecture. Its outstanding performance, flexible deployment options, and rich features make it an ideal choice for MQTT message brokers in edge computing scenarios. Whether for simple IoT applications or complex industrial automation systems, NanoMQ can provide reliable and efficient messaging services.

Project Address: https://github.com/nanomq/nanomq

Leave a Comment