Skip to content

Broker Configuration Reference

This document describes RobustMQ's global/base configuration items. For logging configuration, see Logging.md. Each protocol's own configuration now lives in its own page: MQTT Configuration, Kafka Configuration, AMQP Configuration, NATS Configuration.

Overview

RobustMQ uses TOML format configuration files for system configuration. The main configuration file is config/server.toml.

Configuration Loading Priority

  1. Environment variables (highest)
  2. Configuration file
  3. Default values (lowest)

Environment Variable Override

Configuration file settings can be overridden using environment variables. Naming convention:

text
ROBUST_MQ_SERVER_{SECTION}_{KEY}
  • Top-level items: ROBUST_MQ_SERVER_{KEY}
  • Section items: ROBUST_MQ_SERVER_{SECTION}_{KEY}
  • All letters uppercase, . replaced with _

Examples:

bash
export ROBUST_MQ_SERVER_CLUSTER_NAME="my-cluster"
export ROBUST_MQ_SERVER_MQTT_RUNTIME_SERVER_TCP_PORT=1883
export ROBUST_MQ_SERVER_RUNTIME_CHANNELS_PER_ADDRESS=8

1. Basic Configuration

Top-level configuration items defining cluster and node information.

toml
cluster_name = "robust_mq_cluster_default"
broker_id = 1
broker_ip = "127.0.0.1"
roles = ["broker", "meta"]
grpc_port = 1228
http_port = 58080

[meta_addrs]
1 = "127.0.0.1:1228"
ConfigurationTypeDefaultDescription
cluster_namestring"robust_mq_cluster_default"Cluster name, must be identical across all nodes
broker_idu641Unique node identifier
broker_ipstringAuto-detect local IPNode IP address
rolesarray["broker", "meta"]Node role list, options: meta, broker, engine
grpc_portu321228gRPC service port
http_portu3258080HTTP API service port
meta_addrstable{1 = "127.0.0.1:1228"}Meta node address mapping, key is node ID, value is IP:port

Deployment Modes

  • Integrated deployment: roles = ["meta", "broker", "engine"]
  • Separated deployment:
    • Meta nodes: roles = ["meta"]
    • Broker nodes: roles = ["broker"]
    • Engine nodes: roles = ["engine"]

2. Runtime Configuration

[runtime]

gRPC client connection pool, pprof collection, and global default configuration. Each Tokio runtime's own worker-thread setting now lives under its own table (server_worker_threads stays here; meta_worker_threads is under Meta Runtime Configuration; broker_worker_threads, the MQTT hot-path runtime, is under MQTT Configuration).

toml
[runtime]
channels_per_address = 4
# server_worker_threads = 0  # 0 = auto (recommended)
# pprof_enable = false
ConfigurationTypeDefaultDescription
channels_per_addressusize4Number of HTTP/2 Channels (TCP connections) maintained per gRPC server address
server_worker_threadsusize0 (auto)server-runtime worker threads, auto = max(4, CPU / 2)
pprof_enableboolfalseEnable built-in pprof profiling collection; the resulting flamegraph is exposed via the Admin HTTP API (shares http_port), there is no separate port

Runtime Roles:

RuntimeResponsibilitiesThread Count FieldDefault Threads
server-runtimegRPC service, HTTP Admin API, Prometheus metricsruntime.server_worker_threadsmax(4, CPU/2)
meta-runtimeRaft state machines, RocksDB writesmeta_runtime.meta_worker_threadsmax(4, CPU/2)
broker-runtimeMQTT connection handling, message delivery hot pathmqtt_runtime.broker_worker_threadsCPU cores

Tuning tip: Keep the default 0. Use the tokio_runtime_busy_ratio metric in Grafana to guide adjustments: if a runtime's busy ratio consistently exceeds 80%, consider increasing its thread count.

gRPC client connection pool tuning: Each HTTP/2 Channel supports approximately 200 concurrent Streams (concurrent RPC requests). The default value of 4 supports approximately 800 concurrent gRPC requests, covering the vast majority of production scenarios.

ScenarioRecommended Value
Default / general production4
High concurrency (tens of thousands of MQTT connections)8 ~ 16
Extreme concurrency / stress testing32

Note: Setting this value too high causes a surge in open TCP file descriptors (each Channel occupies one fd). In environments with a low ulimit -n, this may trigger Too many open files.


3. Meta Runtime Configuration

[meta_runtime]

Metadata service heartbeat and Raft configuration.

toml
[meta_runtime]
heartbeat_timeout_ms = 30000
heartbeat_check_time_ms = 1000
raft_write_timeout_sec = 30
offset_raft_group_num = 1
data_raft_group_num = 1
group_offset_expire_sec = 604800
# meta_worker_threads = 0  # 0 = auto, meta-runtime worker threads
ConfigurationTypeDefaultDescription
heartbeat_timeout_msu6430000Node heartbeat timeout (ms); node marked unavailable after timeout
heartbeat_check_time_msu641000Heartbeat check interval (ms)
raft_write_timeout_secu6430Raft write operation timeout (seconds)
offset_raft_group_numu321Number of Offset Raft groups
data_raft_group_numu321Number of Data Raft groups
group_offset_expire_secu64604800Consumer group offset expiry time (seconds), default 7 days
meta_worker_threadsusize0 (auto)meta-runtime worker threads, auto = max(4, CPU / 2)

4. RocksDB Configuration

[rocksdb]

Local RocksDB storage configuration.

toml
[rocksdb]
data_path = "./data"
max_open_files = 10000
ConfigurationTypeDefaultDescription
data_pathstring"./data"RocksDB data storage directory
max_open_filesi3210000Maximum simultaneously open files

5. Storage Engine Runtime Configuration

[storage_runtime]

Journal storage engine runtime configuration.

toml
[storage_runtime]
tcp_port = 1778
max_segment_size = 1073741824
io_thread_num = 8
data_path = []
expire_scan_task_num = 10
offset_enable_cache = true
ConfigurationTypeDefaultDescription
tcp_portu321778Storage engine TCP port
max_segment_sizeu321073741824 (1 GB)Maximum segment file size (bytes)
io_thread_numu328IO processing thread count
data_patharray[]Data storage path list
expire_scan_task_numusize10Concurrent expired data scan tasks
offset_enable_cachebooltrueWhether to enable consumer offset caching

The storage engine's network threads reuse the shared [broker_network] configuration — there is no separate [storage_runtime.network].


6. Delay Task Configuration

[delay_task]

Delayed message processing task queue configuration.

toml
[delay_task]
delay_task_queue_num = 100
delay_task_handler_concurrency = 100
ConfigurationTypeDefaultDescription
delay_task_queue_numusize100Number of delay task queues
delay_task_handler_concurrencyusize100Delay task handler concurrency

7. Broker Network Configuration

[broker_network]

Broker internal general network thread configuration, plus the TLS certificate/key path shared by all protocols.

toml
[broker_network]
accept_thread_num = 2
handler_thread_num = 16
queue_size = 1000
tls_cert = "./config/certs/cert.pem"
tls_key = "./config/certs/key.pem"
ConfigurationTypeDefaultDescription
accept_thread_numusize2Threads for accepting new connections
handler_thread_numusize16Request handler thread count
queue_sizeusize1000Internal processing queue size
tls_certstring"./config/certs/cert.pem"TLS certificate file path (shared by all protocols)
tls_keystring"./config/certs/key.pem"TLS private key file path (shared by all protocols)

8. LLM Client Configuration

[llm_client]

Configures the Broker's unified LLM client (LLMClient). This section is optional. If omitted, the LLM client is not enabled.

toml
[llm_client]
platform = "open_ai"
model = "gpt-4o-mini"
token = "your_api_token"
# Optional: useful for OpenAI-compatible gateways or private deployments
# base_url = "https://api.openai.com/v1/"
# embedding = "text-embedding-3-small"
# embedding_model_path = "./models/embedding"
ConfigurationTypeDefaultDescription
platformstringnoneLLM provider identifier
modelstringnoneModel name, e.g. gpt-4o-mini, claude-3-5-sonnet, gemini-2.0-flash
tokenstringnoneAccess token. Required for all providers except ollama
base_urlstringnoneCustom API base URL (optional)
embeddingstringnoneEmbedding model name (optional)
embedding_model_pathstringnoneLocal embedding model file path (optional)

base_url behavior (important):

  • If base_url is omitted, genai uses the provider's default official endpoint.
  • Set base_url when using a proxy gateway, an OpenAI-compatible service, private deployment, or internal routing.
  • For ollama, if omitted, the default is http://localhost:11434/v1/.

Default endpoint behavior when base_url is omitted:

platformCan omit base_urlDefault endpoint
open_ai / open_ai_respyesOpenAI official
geminiyesGoogle Gemini official
anthropicyesAnthropic official
cohereyesCohere official
xaiyesxAI official
deep_seekyesDeepSeek official
groq / together / fireworks / nebius / mimo / zai / big_modelyesEach provider official
ollamayeshttp://localhost:11434/v1/

Allowed platform values:

  • open_ai, open_ai_resp, gemini, anthropic, fireworks, together, groq
  • mimo, nebius, xai, deep_seek, zai, big_model, cohere, ollama

Environment variable example:

bash
export ROBUST_MQ_SERVER_LLM_CLIENT_PLATFORM=open_ai
export ROBUST_MQ_SERVER_LLM_CLIENT_MODEL=gpt-4o-mini
export ROBUST_MQ_SERVER_LLM_CLIENT_TOKEN=your_api_token

9. Admin HTTP API Authentication

[admin]

Authentication configuration for the Admin HTTP API. See API Authentication for details.

toml
[admin]
username = "admin"
password = "admin"
jwt_secret = "robustmq-change-me-in-production"
token_ttl_hours = 8
FieldTypeDefaultDescription
usernamestring"admin"Admin username
passwordstring"admin"Admin password — change this in production
jwt_secretstring"robustmq-change-me-in-production"HMAC-SHA256 secret used to sign JWT tokens — use a random string of 32+ chars in production
token_ttl_hoursu648Token validity period in hours

⚠️ Security notice: The default password and jwt_secret values are insecure. Always change them before deploying to production.

Auth rules:

  • Requests from 127.0.0.1 / ::1 (loopback): no token required, allowed through directly
  • Requests from any other IP: must include Authorization: Bearer <token>
  • /api/v1/login, /health/*, /metrics: always public, no auth required

10. Monitoring & Profiling

RobustMQ has no separate [prometheus] or [pprof] configuration section — both reuse the Admin HTTP API's http_port and have no dedicated configurable port:

  • Prometheus metrics: always exposed via GET /metrics on the Admin HTTP API (see http_port in Basic Configuration); there is no enable/disable switch or separate port.
  • pprof profiling: controlled by runtime.pprof_enable (see 2. Runtime Configuration); the resulting flamegraph is likewise exposed via the Admin HTTP API — there is no separate port/frequency configuration.

Complete Configuration Example

This example covers every base configuration item. See each protocol's own page for its full example: MQTT, Kafka, AMQP, NATS.

toml
# ========== Basic Configuration ==========
cluster_name = "production-cluster"
broker_id = 1
roles = ["meta", "broker", "engine"]
grpc_port = 1228
http_port = 58080

[meta_addrs]
1 = "192.168.1.10:1228"
2 = "192.168.1.11:1228"
3 = "192.168.1.12:1228"

# ========== Runtime ==========
[runtime]
channels_per_address = 4
# server_worker_threads = 0
# pprof_enable = false

# ========== Meta ==========
[meta_runtime]
heartbeat_timeout_ms = 30000
heartbeat_check_time_ms = 1000
raft_write_timeout_sec = 30
offset_raft_group_num = 1
data_raft_group_num = 1
group_offset_expire_sec = 604800
# meta_worker_threads = 0

# ========== RocksDB ==========
[rocksdb]
data_path = "/data/robustmq"
max_open_files = 20000

# ========== Storage Engine ==========
[storage_runtime]
tcp_port = 1778
max_segment_size = 1073741824
io_thread_num = 8
expire_scan_task_num = 10
offset_enable_cache = true

# ========== Delay Task ==========
[delay_task]
delay_task_queue_num = 100
delay_task_handler_concurrency = 100

# ========== Broker Network ==========
[broker_network]
accept_thread_num = 2
handler_thread_num = 16
queue_size = 1000
tls_cert = "./config/certs/cert.pem"
tls_key = "./config/certs/key.pem"

# ========== LLM Client (optional) ==========
[llm_client]
platform = "open_ai"
model = "gpt-4o-mini"
token = "your_api_token"
# base_url = "https://api.openai.com/v1/"
# embedding = "text-embedding-3-small"
# embedding_model_path = "./models/embedding"

# ========== Admin Authentication ==========
[admin]
username = "admin"
password = "your_secure_password"
jwt_secret = "your-random-jwt-secret-32-chars-min"
token_ttl_hours = 8

# ========== Logging ==========
[log]
log_config = "./config/broker-tracing.toml"
log_path = "./logs"
🎉 既然都登录了 GitHub,不如顺手给我们点个 Star 吧!⭐ 你的支持是我们最大的动力 🚀