This page provides a high-level introduction to RobustMQ, a next-generation unified messaging infrastructure built in Rust. It covers:
For detailed information about specific subsystems, see:
Sources: README.md1-175 docs/zh/ContributionGuide/ContributingCode/Code-Structure.md1-280
RobustMQ is designed as a unified messaging infrastructure that consolidates multiple messaging protocols and storage strategies into a single platform. The primary design goals are:
| Workload Type | Use Case | Key Feature |
|---|---|---|
| AI | Agent communication, training data ingestion | Lightweight topics, shared subscriptions, storage tiering |
| IoT | Device telemetry, command/control | MQTT ingestion with Kafka consumption on same data plane |
| Data | Stream processing, analytics | Flexible storage modes (memory/hybrid/persistent/tiered) |
Sources: README.md41-59 README.md61-73
RobustMQ implements a three-tier architecture with isolated runtime execution contexts:
BrokerServer creates three separate Tokio runtimes to prevent resource contention between gRPC handling, Raft consensus operations (~9 internal tasks per shard), and protocol message processingMetaServiceServer uses multi-Raft groups (metadata, offset, data) for distributed consensusStorageDriverManager and StorageAdapter trait enable memory, RocksDB, MySQL, PostgreSQL, and S3 backendsClientPool manages gRPC client connections with configurable channels per addressSources: src/broker-server/src/lib.rs86-108 src/broker-server/src/lib.rs116-238 Architecture diagrams
| Component | File Path | Primary Responsibility |
|---|---|---|
BrokerServer | src/broker-server/src/lib.rs86-239 | Main server orchestration, runtime management, component lifecycle |
MetaServiceServer | src/meta-service/ | Cluster metadata storage, Raft consensus, node registration/heartbeat |
MqttBrokerServer | src/mqtt-broker/src/broker.rs70-345 | MQTT protocol handling, session management, QoS delivery |
StorageEngineServer | src/storage-engine/ | Message persistence, segment-based file storage, offset tracking |
AdminServer | src/admin-server/ | HTTP REST API for cluster management and monitoring |
ClientPool | src/grpc-clients/ | gRPC client connection pooling and load balancing |
StorageDriverManager | src/storage-adapter/ | Pluggable storage abstraction, per-topic storage routing |
ConnectorManager | src/connector/ | Data egress to 17+ external systems (Kafka, databases, etc.) |
Sources: src/broker-server/src/lib.rs86-239 src/mqtt-broker/src/broker.rs50-128 Cargo.toml304-350
RobustMQ implements multiple messaging protocols with protocol-specific optimizations:
| Protocol | Status | Implementation | Key Features |
|---|---|---|---|
| MQTT 3.x/5.0 | ✅ Stable | src/mqtt-broker/ | QoS 0/1/2, retained messages, shared subscriptions, session persistence |
| Kafka | 🚧 In Progress | src/kafka-broker/ | Protocol compatibility for AI training data ingestion |
| AMQP | 🚧 Planned | src/amqp-broker/ | Enterprise messaging patterns |
Network transport options:
Sources: README.md76-77 src/mqtt-broker/Cargo.toml1-93 Cargo.toml148-153
Storage Configuration Options:
The StorageDriverManager routes storage operations per-topic based on configuration, enabling different topics to use different storage strategies within the same cluster.
Sources: src/storage-adapter/ src/storage-engine/ Architecture Diagram 4
RobustMQ provides data egress connectors to integrate with external systems:
| Category | Connectors | Configuration |
|---|---|---|
| Message Queues | Kafka, Pulsar, RabbitMQ, MQTT Bridge | src/connector/config_kafka.rs src/connector/config_pulsar.rs |
| Databases | MySQL, PostgreSQL, MongoDB, Cassandra | src/connector/config_mysql.rs src/connector/config_mongodb.rs |
| Time Series | GreptimeDB, InfluxDB, OpenTSDB | src/connector/config_greptimedb.rs src/connector/config_influxdb.rs |
| Search/Analytics | Elasticsearch, ClickHouse | src/connector/config_elasticsearch.rs src/connector/config_clickhouse.rs |
| Storage | S3/MinIO, Local File, Redis | src/connector/config_s3.rs src/connector/config_local_file.rs |
| Other | Webhook | src/connector/config_webhook.rs |
Each connector runs in a dedicated thread managed by ConnectorManager with metrics tracking (send_success_total, send_fail_total). Failure handling strategies include:
Sources: src/admin-server/src/mqtt/connector.rs1-448 Architecture Diagram 7
The AuthManager provides pluggable authentication with multiple backend support:
| Authentication Mode | Backend | Configuration |
|---|---|---|
| Secret-Free | No authentication | Development mode |
| Password-Based | MySQL, Placement Storage, Redis | Configurable via auth_driver |
| Authorization | ACL validation, blacklist checking | Topic-level permissions |
Hash algorithms supported: MD5, SHA1, SHA256, bcrypt, PBKDF2, HMAC-SHA256
Sources: src/mqtt-broker/src/security/ src/mqtt-broker/Cargo.toml74-86 Architecture Diagram 6
RobustMQ uses three isolated Tokio runtimes to prevent task scheduler contention:
Worker thread counts are configurable and independently tuned:
| Runtime | Config Key | Purpose | Default Calculation |
|---|---|---|---|
server_runtime | runtime.server_worker_threads | gRPC, HTTP, admin tasks | num_cpus() / 4 |
meta_runtime | runtime.meta_worker_threads | Raft consensus operations | num_cpus() / 4 |
broker_runtime | runtime.broker_worker_threads | Protocol message processing | num_cpus() / 2 |
The blog documents that 16 threads per runtime achieved 20k+ ops/s on a 14-CPU machine, demonstrating that slight oversubscription improves throughput.
Critical Design Decision: Raft's Raft::new() is called inside meta_runtime.block_on() so all openraft internal tasks (approximately 9 per shard: core loop, log I/O, state machine, snapshot builder, replication, heartbeat) are spawned on the meta runtime. This prevents interference with latency-sensitive protocol handling on the broker runtime.
Sources: src/broker-server/src/lib.rs126-131 src/broker-server/src/lib.rs161-193 common/base/src/runtime.rs Architecture Diagram 2
RobustMQ follows a phased development roadmap:
| Phase | Status | Focus | Deliverables |
|---|---|---|---|
| Phase 1 | ✅ Completed | Foundation | Scalable architecture, pluggable storage, multi-protocol support |
| Phase 2 | ✅ Initial Release | MQTT Broker | MQTT 3.x/5.0 support, <20MB binary for edge deployment |
| Phase 3 | 🚧 In Progress | Kafka Protocol & AI | AI training data caching, million-scale lightweight topics, Kafka compatibility |
Sources: README.md61-73 README.md38-39
RobustMQ compiles to a single binary (broker-server) that includes all components:
Main configuration file: config/server.toml
Key configuration sections:
cluster: Cluster name, node ID, roles (broker/meta/engine)grpc_port, http_port: Service portsruntime: Worker thread counts for each runtimerocksdb: RocksDB storage settingsprometheus: Metrics collection settingsp_prof: Performance profiling settingsSources: README.md85-117 makefile28-42 src/broker-server/src/lib.rs240-435
For detailed information about specific subsystems:
Architecture Details: System Architecture
MQTT Broker: MQTT Broker
Storage Layer: Storage Layer
Meta Service: Meta Service
Connector System: Bridge and Connector System
Operations: Management and Operations
Build and Test: Build, Test, and Deployment
Sources: Table of contents JSON structure
Refresh this wiki