This guide provides comprehensive information about RustMQ configuration files, their usage, and best practices for different environments.
RustMQ uses a well-structured configuration system with separate files for different environments and use cases. All configuration files are located in the config/ directory.
config/broker.toml- Production broker configurationconfig/controller.toml- Production controller configurationconfig/example-production.toml- Production template with detailed comments
config/broker-dev.toml- Development broker configurationconfig/controller-dev.toml- Development controller configurationconfig/example-development.toml- Comprehensive development templateconfig/admin-dev.toml- Development admin configuration
config/test-broker.toml- Optimized test broker configurationconfig/test-controller.toml- Optimized test controller configuration
config/controller-simple.toml- Minimal controller setupconfig/admin-rate-limiting-example.toml- Rate limiting configuration examples
The existing test configurations are already optimal for testing scenarios:
# Unit tests - use existing test configs
cargo test --lib
# Integration tests with test configs
RUSTMQ_BROKER_CONFIG=config/test-broker.toml cargo test --test integration
# Start test services
cargo run --bin rustmq-broker -- --config config/test-broker.toml
cargo run --bin rustmq-controller -- --config config/test-controller.tomlTest Configuration Features:
- ✅ Use
/tmpdirectories for ephemeral test data - ✅ Disabled
fsync_on_write = falsefor speed - ✅ Small cache sizes (16MB/32MB) for efficient testing
- ✅ Short timeouts for fast test iteration
- ✅ Single replication factor for simplicity
- ✅ Local storage only (no cloud dependencies)
# Start development services
cargo run --bin rustmq-broker -- --config config/broker-dev.toml
cargo run --bin rustmq-controller -- --config config/controller-dev.toml
# Use development example configuration
cargo run --example producer -- --config config/example-development.tomlDevelopment Configuration Features:
- ✅ Local filesystem paths under
./data/ - ✅ Security enabled with self-signed certificates
- ✅ Debug logging level
- ✅ Smaller resource allocations for local development
- ✅ Fast iteration settings (shorter timeouts, smaller segments)
# Start production services
cargo run --bin rustmq-broker -- --config config/broker.toml
cargo run --bin rustmq-controller -- --config config/controller.toml
# Use production template as starting point
cp config/example-production.toml config/my-production.toml
# Edit my-production.toml for your environment
cargo run --bin rustmq-broker -- --config config/my-production.tomlProduction Configuration Features:
- ✅ Cloud storage backends (S3/GCS/Azure)
- ✅ Production-grade security with proper certificates
- ✅ Large cache sizes and optimized performance settings
- ✅ Comprehensive monitoring and metrics
- ✅ High availability and replication settings
[network]
quic_listen = "0.0.0.0:9092" # QUIC/HTTP3 client endpoint
rpc_listen = "0.0.0.0:9093" # Internal gRPC endpoint
max_connections = 10000 # Maximum concurrent connections
connection_timeout_ms = 30000 # Connection timeout[wal]
path = "/var/lib/rustmq/wal" # WAL storage path
capacity_bytes = 10737418240 # 10GB WAL capacity
fsync_on_write = true # Force sync on write (durability)
segment_size_bytes = 1073741824 # 1GB segment size
[cache]
write_cache_size_bytes = 1073741824 # 1GB hot data cache
read_cache_size_bytes = 2147483648 # 2GB cold data cache
eviction_policy = "Moka" # Cache eviction policy
[object_storage]
storage_type = "S3" # Storage backend (S3/Gcs/Azure/Local)
bucket = "rustmq-data" # Storage bucket name
region = "us-central1" # Storage region[security]
enabled = true
tls_cert_path = "./certs/server.pem"
tls_key_path = "./certs/server.key"
ca_cert_path = "./certs/ca.pem"
require_client_cert = true[raft]
data_dir = "./data/raft"
heartbeat_interval_ms = 500
election_timeout_ms = 2000
max_append_entries_size = 1000
[cluster]
initial_cluster = ["controller-01=127.0.0.1:9095"][admin]
port = 9642 # Admin REST API port
health_check_interval_ms = 15000 # Health check interval
health_timeout_ms = 30000 # Health timeout
enable_cors = true # Enable CORS headers
# Rate limiting configuration
[admin.rate_limiting]
enabled = true # Enable rate limiting
global_burst_size = 1000 # Global burst capacity
global_refill_rate = 60 # Global requests per minuteRustMQ supports configuration through environment variables for containerized deployments:
# Core settings
RUSTMQ_BROKER_ID=broker-001
RUSTMQ_RACK_ID=us-central1-a
RUSTMQ_LOG_LEVEL=info
# Storage settings
RUSTMQ_WAL_PATH=/var/lib/rustmq/wal
RUSTMQ_STORAGE_BUCKET=rustmq-data
RUSTMQ_STORAGE_REGION=us-central1
# GCP settings
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
GCP_PROJECT_ID=your-project-id
# Performance tuning
RUSTMQ_CACHE_SIZE=2147483648
RUSTMQ_MAX_CONNECTIONS=10000
RUSTMQ_BATCH_SIZE=1000
# Admin API rate limiting settings
RUSTMQ_ADMIN_RATE_LIMITING_ENABLED=true
RUSTMQ_ADMIN_GLOBAL_BURST_SIZE=1000
RUSTMQ_ADMIN_GLOBAL_REFILL_RATE=60- Use existing development configs:
config/broker-dev.tomlandconfig/controller-dev.tomlare pre-configured for local development - Enable debug logging: Set
level = "debug"in logging section - Use local storage: Configure
storage_type = "local"for faster iteration - Smaller resource allocations: Use smaller cache sizes and buffer configurations
- Use existing test configs:
config/test-broker.tomlandconfig/test-controller.tomlare optimized for testing - Ephemeral storage: Test configs use
/tmpdirectories that are cleaned up automatically - Disable fsync:
fsync_on_write = falsefor faster test execution - Short timeouts: Quick failure detection for fast test iteration
- Start with production template: Use
config/example-production.tomlas a starting point - Configure cloud storage: Set up proper S3/GCS/Azure credentials and regions
- Enable security: Use production certificates and enable all security features
- Monitor resource usage: Configure appropriate cache sizes and connection limits
- Set up proper logging: Use structured logging with appropriate log levels
RustMQ automatically validates configuration on startup:
# Validate broker configuration
cargo run --bin rustmq-broker -- --config config/broker.toml --validate
# Validate controller configuration
cargo run --bin rustmq-controller -- --config config/controller.toml --validate-
Invalid TOML syntax
# Check for syntax errors cargo run --bin rustmq-broker -- --config config/broker.toml # Look for "failed to parse configuration" errors
-
Missing required fields
# Ensure all required fields are present # Compare with example configurations diff config/broker.toml config/example-production.toml
-
Permission issues
# Check file permissions ls -la config/ # Ensure configuration files are readable chmod 644 config/*.toml
-
Path issues
# Ensure directories exist mkdir -p /var/lib/rustmq/wal mkdir -p ./data/wal
# Test configuration loading
cargo test config::
# Validate specific configurations
cargo run --bin rustmq-broker -- --config config/test-broker.toml --dry-run
cargo run --bin rustmq-controller -- --config config/test-controller.toml --dry-runWhen upgrading RustMQ versions, use the provided migration tools:
# Migrate configuration to new version
cargo run --bin rustmq-admin -- config migrate \
--from config/old-broker.toml \
--to config/new-broker.toml \
--version 1.1.0[object_storage]
storage_type = { Custom = {
endpoint = "https://custom-s3.example.com",
access_key_id = "custom-access-key",
secret_access_key = "custom-secret-key",
region = "custom-region"
}}# High-throughput configuration
[wal]
buffer_size = 1048576 # 1MB buffer for high throughput
segment_size_bytes = 2147483648 # 2GB segments
# Low-latency configuration
[wal]
buffer_size = 4096 # Small buffers for low latency
flush_interval_ms = 1 # Immediate flush[security]
require_client_cert = true
min_tls_version = "1.3"
cipher_suites = ["TLS_AES_256_GCM_SHA384"]
enable_cert_revocation_check = true