Comprehensive performance optimization skill for MQTTX applications.
This skill provides tools, templates, and guides for optimizing MQTTX application performance across various scenarios including high-throughput IoT gateways, low-latency control systems, resource-constrained edge devices, and mobile applications.
mqttx-performance/ ├── SKILL.md # Main skill documentation ├── assets/ │ └── performance-tuning.go.tmpl # Complete performance configuration examples ├── scripts/ │ └── benchmark.sh # Automated benchmark testing script └── references/ └── performance-guide.md # Detailed optimization guide
The main skill entry point containing:
Complete Go code templates for:
Automated benchmark script providing:
Usage:
cd /workspace/docs/skills/mqttx-performance/scripts
chmod +x benchmark.sh
# Run all benchmarks
./benchmark.sh
# Run specific benchmarks
./benchmark.sh --basic --cpu
# Customize duration
BENCHMARK_TIME=60s ./benchmark.sh --basic
# See all options
./benchmark.sh --help
Comprehensive optimization guide covering:
cat /workspace/docs/skills/mqttx-performance/SKILL.md
# Copy template to your project
cp /workspace/docs/skills/mqttx-performance/assets/performance-tuning.go.tmpl \
/your/project/performance-config.go
# Edit and adapt to your needs
vim /your/project/performance-config.go
cd /workspace/docs/skills/mqttx-performance/scripts
./benchmark.sh
cat /workspace/docs/skills/mqttx-performance/references/performance-guide.md
assets/performance-tuning.go.tmpl → createHighThroughputSession()assets/performance-tuning.go.tmpl → createLowLatencySession()assets/performance-tuning.go.tmpl → createConstrainedSession()assets/performance-tuning.go.tmpl → createResilientSession()The skill includes a complete performance monitoring system:
// Start monitoring
monitor := NewPerformanceMonitor(manager, 10*time.Second)
monitor.Start()
defer monitor.Stop()
// Get metrics history
history := monitor.GetHistory()
// Report session metrics
reportSessionMetrics(manager, "session-name")
See assets/performance-tuning.go.tmpl for complete implementation.
Run comprehensive benchmarks:
# Full benchmark suite
./scripts/benchmark.sh
# Quick benchmarks only
./scripts/benchmark.sh --basic
# With profiling
./scripts/benchmark.sh --cpu --mem
# Custom duration
BENCHMARK_TIME=120s ./scripts/benchmark.sh
Results are saved in ./benchmark-results/ directory.
/workspace/docs/性能调优指南.md - Chinese performance tuning guide/workspace/docs/PERFORMANCE_GUIDE.md - English performance guide/workspace/benchmark_test.go - Benchmark test implementations/workspace/types.go - PerformanceOptions type definitionsOn standard hardware (4-core CPU, 8GB RAM):
| Metric | Target | Configuration |
|---|---|---|
| Throughput | 100K+ msg/sec | High-throughput config |
| Latency | <10ms | Low-latency config |
| Memory per session | <10MB | Default config |
| Connection capacity | 1000+ sessions | Multi-session config |
| Error rate | <0.1% | Proper error handling |
| Reconnect time | <5s | Auto-reconnect enabled |
| Issue | Solution |
|---|---|
| Message backlog | Increase MessageChanSize, add workers |
| High latency | Reduce buffer sizes, use QoS 0 |
| Memory leaks | Stop unused routes, clean up sessions |
| Connection failures | Increase timeouts, use multiple brokers |
| High CPU | Use batch processing, optimize handlers |
| GC pressure | Reduce allocations, increase limits |
See references/performance-guide.md for detailed troubleshooting steps.
To improve this skill:
assets/scripts/references/SKILL.mdPart of the MQTTX project. See project LICENSE for details.
For performance issues or questions: