rzmq is an ongoing effort to build a high-performance, asynchronous pure Rust implementation of the ZeroMQ (ØMQ) messaging library. It leverages the Tokio runtime for its asynchronous capabilities and aims to provide a familiar ZeroMQ API within the modern Rust ecosystem.
A primary focus of rzmq
is to deliver leading performance on Linux. By integrating an advanced io_uring
backend with TCP Corking, rzmq
has demonstrated superior throughput and lower latency compared to other ZeroMQ implementations, including the C-based libzmq
, in high-throughput benchmark scenarios.
rzmq
is currently in Beta. While core functionality and significant performance advantages (on Linux with io_uring
) are in place, users should be aware of the following:
- API Stability: The public API is stabilizing but may still see minor refinements before a 1.0 release.
- Feature Scope: The focus is on core ZMTP 3.1 compliance and popular patterns. Full feature parity with all of
libzmq
's extensive options and advanced behaviors is a non-goal. Notably, CURVE security and ZAP (ZeroMQ Authentication Protocol) are not supported and are not planned. - Interoperability:
rzmq
aims for wire-level interoperability withlibzmq
and other standard ZMTP 3.1 implementations for supported socket patterns using NULL or PLAIN security. The Noise_XX mechanism offered byrzmq
is specific to this library. - Testing Environment: Primarily tested on macOS (ARM & x86) and Linux (Kernel 6.x). The
io_uring
backend is Linux-specific and best tested on Kernel 6.x+. Windows is not currently supported. - Performance: While leading performance is a key achievement, comprehensive benchmarking across all diverse workloads and hardware is ongoing.
- Robustness: Tested for common use cases; edge case hardening is continuous.
- Pure Rust & Async Native: Memory safety, seamless
async/await
integration with Tokio, and no Clibzmq
dependency. - High Performance on Linux: Specifically designed to leverage
io_uring
for superior throughput and low latency, as demonstrated in benchmarks. - Modern Security: Prioritizes strong, modern security with the inclusion of Noise_XX, a departure from
libzmq
's traditional CURVE. - Learning & Innovation: A platform to explore messaging system architecture in Rust.
rzmq
(core
crate) currently supports:
- Core ZeroMQ API:
Context
,Socket
handle with asyncbind
,connect
,send
,recv
,set_option_raw
,get_option
,close
,term
. - Standard Socket Types:
REQ
,REP
,PUB
,SUB
,PUSH
,PULL
,DEALER
,ROUTER
. - Transports:
tcp://
(IPv4/IPv6), with an optional high-performanceio_uring
backend on Linux.ipc://
(Unix Domain Sockets,ipc
feature, Unix-like systems).inproc://
(In-process,inproc
feature).
- ZMTP 3.1 Protocol: Core elements including Greeting, Framing, READY, PING/PONG.
- Common Socket Options:
- Watermarks (
SNDHWM
,RCVHWM
), Timeouts (SNDTIMEO
,RCVTIMEO
,LINGER
), Reconnection (RECONNECT_IVL
,RECONNECT_IVL_MAX
), TCP Keepalives,LAST_ENDPOINT
. - Pattern-specific:
SUBSCRIBE
,UNSUBSCRIBE
,ROUTING_ID
,ROUTER_MANDATORY
. - ZMTP Heartbeats (
HEARTBEAT_IVL
,HEARTBEAT_TIMEOUT
),HANDSHAKE_IVL
. - Security:
PLAIN_SERVER/USERNAME/PASSWORD
,NOISE_XX_ENABLED/STATIC_SECRET_KEY/REMOTE_STATIC_PUBLIC_KEY
(noise_xx
feature). - Linux Performance (
io-uring
feature):IO_URING_SESSION_ENABLED
,TCP_CORK
,IO_URING_SNDZEROCOPY
,IO_URING_RCVMULTISHOT
.
- Watermarks (
- Socket Monitoring: Event system (
Socket::monitor()
) for lifecycle events. - Supported Security Mechanisms:
- NULL (interoperable)
- PLAIN (interoperable)
- Noise_XX (experimental,
noise_xx
feature,rzmq
-specific, not interoperable withlibzmq
CURVE)
Goals:
- Stability and Robustness: Achieve production-grade stability.
- Leading Performance: Continue to optimize, especially the
io_uring
path on Linux. - Ease of Use: Provide a Rust-idiomatic and intuitive API.
- Modern Security: Offer strong, modern security options like Noise_XX.
- Community and Documentation: Foster an active community with clear documentation.
Non-Goals:
- Full
libzmq
Feature Parity: Replicating every single feature and option oflibzmq
is not intended. - Support for CURVE or ZAP: These
libzmq
security features are not planned for implementation.rzmq
focuses on NULL, PLAIN, and its own Noise_XX mechanism.
- Performance-Critical Linux Applications: When seeking the highest possible messaging throughput and lowest latency, leveraging
70DC
the
io_uring
backend. - Pure Rust Environments: To avoid C dependencies and benefit from Rust's safety and async ecosystem.
- Modern Security Needs: If Noise_XX is a desired security protocol for
rzmq
-to-rzmq
communication. - Learning & Contribution: For those interested in ZeroMQ internals, asynchronous Rust,
io_uring
, or contributing to a modern messaging library.
For applications requiring the broadest libzmq
feature set, maximum existing ecosystem compatibility (e.g., with CURVE/ZAP), or support for platforms beyond macOS/Linux, the official C libzmq
(typically via Rust bindings like zmq-rs
) remains the established choice.
This repository may contain multiple crates:
core/
: The mainrzmq
library implementation. (Seecore/README.md
for detailed information about the library itself).cli/
: Command Line Utility to help generate NoiseXX keys. (Seecli/README.md
for detailed information about the cli itself).
Please refer to the core/README.md
for detailed installation instructions, prerequisites, API usage, and examples.
rzmq
is licensed under the Mozilla Public License Version 2.0 (MPL-2.0). This means you are free to use, modify, and distribute it under the terms of the MPL-2.0, which requires that modifications to MPL-licensed files be made available under the same license.