FluxMQ
A high-performance, Kafka-compatible message broker written in Rust with 100% Java client compatibility and 608k+ msg/sec throughput.
๐ Features
- 100% Java Kafka Compatible: Complete compatibility with Java Kafka clients (apache-kafka-java 4.1+)
- Ultra High Performance: 608,272+ messages/second throughput with Arena Memory optimizations
- 20 Kafka APIs Supported: Full wire protocol compatibility with metadata, produce, consume, and admin operations
- Distributed Architecture: Leader-follower replication with Raft-like consensus
- Consumer Groups: Load balancing across multiple consumers with partition assignment
- Persistent Storage: Hybrid memory-disk storage with crash recovery
- Multi-Partition Topics: Hash-based and round-robin partition assignment strategies
- Async Architecture: Built on Tokio for high-concurrency message processing
๐ Performance
๐ Latest Benchmark Results (2025-09-14)
- MegaBatch Performance: 608,272 messages/second (1MB batch size, 16 threads)
- Java Client Compatibility: 100% working with all major Java Kafka libraries
- Sequential I/O: 20-40x HDD, 5-14x SSD performance improvement
- Lock-Free Metrics: 99.9% performance recovery with optimized atomic operations
- Zero-Copy Design: Memory-mapped I/O with
bytes::Bytesfor maximum efficiency - Sub-millisecond latency: 0.019-0.030 ms/message processing time
๐ฏ Proven Client Support
- โ
Java:
org.apache.kafka:kafka-clientsv4.1+ (100% compatible) - โ
Python:
kafka-pythonlibrary support - โ Scala: Native Kafka Scala clients
- โ Admin Operations: Topic creation, deletion, metadata queries
๐๏ธ Architecture
Core Components
- Broker: TCP server handling client connections
- Storage Engine: Hybrid memory-disk persistence layer
- Topic Manager: Multi-partition topic management
- Replication Coordinator: Leader-follower data replication
- Consumer Group Coordinator: Load balancing and partition assignment
- Network Protocol: Binary protocol with length-prefixed frames
Storage Layer
- In-memory operations: Primary read/write for maximum performance
- Async disk persistence: Background writes for durability
- Memory-mapped I/O: Efficient file operations for large datasets
- Append-only logs: Sequential writes with CRC integrity checks
๐ ๏ธ Installation
Prerequisites
- Rust 1.70+ (latest stable recommended)
- Cargo package manager
Build from source
๐ Quick Start
Start a basic broker
Start with all features enabled
# For core development
# Or with full features
RUSTFLAGS="-C target-cpu=native"
Multi-broker cluster setup
# Terminal 1: Broker 1
# Terminal 2: Broker 2
# Terminal 3: Broker 3
๐ Usage Examples
๐ Java Client Example (100% Compatible)
// Producer Example
;
;
;
๐ Python Example
# Producer
=
# Consumer
=
break
๐ฆ Rust Native Example
Producer Example
use *;
async
Consumer Example
use *;
use StreamExt;
async
Try the examples
# Terminal 1: Start FluxMQ broker
RUSTFLAGS="-C target-cpu=native"
# Terminal 2: Run Java benchmark (601k+ msg/sec)
# Terminal 3: Run simple Java test
# Or try Rust examples
โ๏ธ Configuration
Command Line Options
Environment Variables
RUST_LOG=debug # Enable debug logging
FLUXMQ_DATA_DIR=/var/lib/fluxmq # Override data directory
๐งช Testing
Run all tests
Run specific test modules
Performance benchmarks
๐ Project Structure
src/
โโโ main.rs # Application entry point
โโโ lib.rs # Library root
โโโ broker/ # Broker implementation
โ โโโ handler.rs # Request handlers
โ โโโ server.rs # TCP server
โโโ storage/ # Storage layer
โ โโโ log.rs # Append-only log files
โ โโโ segment.rs # Log segment management
โ โโโ index.rs # Offset indexing
โโโ protocol/ # Network protocol
โ โโโ messages.rs # Protocol messages
โ โโโ codec.rs # Server-side codec
โ โโโ client_codec.rs # Client-side codec
โโโ replication/ # Replication system
โ โโโ leader.rs # Leader state management
โ โโโ follower.rs # Follower synchronization
โโโ consumer/ # Consumer groups
โ โโโ coordinator.rs # Group coordinator
โโโ topic_manager.rs # Topic management
๐ง Development
Prerequisites
# Install Rust
|
# Install development dependencies
Development commands
# Format code
# Check for issues
# Security audit
# Watch for changes
๐ฏ Roadmap
โ Completed (v2.0 - 2025-09)
- 100% Java Kafka Client Compatibility (apache-kafka-java 4.1+)
- 601k+ msg/sec Performance with MegaBatch optimization
- 20 Kafka APIs Implemented (Metadata, Produce, Fetch, Consumer Groups, Admin)
- Sequential I/O Optimization (20-40x HDD, 5-14x SSD improvement)
- Lock-Free Metrics System with atomic operations
- Ultra-Performance Storage (Memory-mapped I/O, SIMD processing)
- Enterprise Security (TLS/SSL, ACL, SASL authentication)
- Leader-Follower Replication with Raft-like consensus
๐ In Progress
- Advanced monitoring dashboard
- Kubernetes operator development
- Schema registry integration
- Additional client SDK support
๐ Future
- Log compaction
- Schema registry integration
- Kubernetes operator
- Web-based management UI
๐ค Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development workflow
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run the test suite
- Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Inspired by Apache Kafka's architecture
- Built with the amazing Rust ecosystem
- Special thanks to the Tokio team for async runtime
๐ Support
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ง Email: hsng95@gmail.com
FluxMQ - High-performance message streaming, built with Rust โก๏ธ