RabbitMQ Enhancement Roadmap
This document lists identified opportunities where RabbitMQ-native features could significantly improve the NSB architecture. These are engineering proposals ranging from low-effort improvements to longer-term redesigns.
1. Message Priority Queuesโ
Current Stateโ
All messages are treated equally. The nsb.recv.{client_id} queues process messages in FIFO order.
Opportunityโ
RabbitMQ supports priority queues (up to 255 priority levels). This could enable:
- Control messages (INIT, PING, EXIT) to take precedence over data messages
- Urgent simulation events to bypass queued payloads
- QoS simulation where high-priority network traffic is modeled
Impactโ
- More realistic network simulation (priority-based routing)
- Better responsiveness for control-plane operations
- Enables modeling of DiffServ or similar QoS mechanisms
2. Dead Letter Exchanges (DLX) for Message Trackingโ
Current Stateโ
Messages that fail to be processed or time out are silently dropped with no visibility.
Opportunityโ
RabbitMQ's Dead Letter Exchanges can capture:
- Messages that exceed TTL (simulating network timeouts/drops)
- Rejected or failed messages
- Messages from deleted queues (client disconnection)
Impactโ
- Debugging: Track why messages weren't delivered
- Metrics: Count dropped packets for simulation accuracy
- Timeout simulation: Model network latency/drops via per-message TTL
- Audit trail: Log all failed communications
3. Topic Exchange for Multicast/Broadcastโ
Current Stateโ
The implementation uses a direct exchange with point-to-point routing (nsb.recv.{client_id}). Broadcasting requires sending to each client individually.
Opportunityโ
A topic exchange enables:
- Multicast:
nsb.recv.group.*โ all nodes in a group - Broadcast:
nsb.recv.#โ all nodes - Hierarchical addressing:
nsb.recv.datacenter1.rack2.node5
Impactโ
- Efficient broadcast: single publish reaches all subscribers
- Group communication: model network segments, VLANs, multicast groups
- Hierarchical networks: natural fit for datacenter and IoT topologies
4. Message TTL for Network Latency Simulationโ
Current Stateโ
Messages are delivered as fast as possible. Network latency must be simulated externally.
Opportunityโ
RabbitMQ's per-message TTL and delayed message plugins can model:
- Network propagation delay
- Congestion-induced delays
- Timeout behaviors at the transport layer
There is a design question here โ it may be better to isolate latency modeling within the network simulator rather than the broker. This is not a clear win and warrants discussion.
Impactโ
- Realistic latency modeling without application-level
sleep() - Configurable per-link delays for heterogeneous networks
- Decoupled timing from application logic
5. Publisher Confirms for Reliable Deliveryโ
Current Stateโ
basic_publish() is fire-and-forget. There is no confirmation that messages reached the broker.
Opportunityโ
Publisher confirms provide acknowledgment that messages were:
- Received by the broker
- Persisted to disk (if durable queues are configured)
- Routed to at least one queue
Impactโ
- Guaranteed delivery for critical simulation events
- Error detection when a destination doesn't exist
- Flow control to prevent overwhelming the broker
6. Consumer Prefetch for Flow Controlโ
Current Stateโ
The _recv_msg() implementation uses basic_get(), which polls one message at a time.
Opportunityโ
Prefetch (QoS) settings can:
- Batch message retrieval for higher throughput
- Limit in-flight messages to prevent memory exhaustion
- Balance load across multiple consumers
Impactโ
- Higher throughput for high-volume simulations
- Backpressure prevents fast producers from overwhelming slow consumers
- Fair dispatch across multiple simulator instances
7. Quorum Queues for High Availabilityโ
Current Stateโ
Single-node RabbitMQ setup. Queue data is lost if the broker crashes.
Opportunityโ
Quorum queues provide:
- Replicated queues across a RabbitMQ cluster
- Automatic leader election on failure
- Strong data safety guarantees
Impactโ
- Fault tolerance for long-running simulations
- No message loss during broker restarts
- Distributed deployment for large-scale simulations
8. Streams for Event Sourcing / Replayโ
Current Stateโ
Messages are consumed and deleted. No mechanism exists to replay simulation events.
Opportunityโ
RabbitMQ Streams (v3.9+) provide:
- Persistent, append-only log of messages
- Multiple consumers can read from any offset
- Full replay capability
Impactโ
- Simulation replay for debugging
- Event sourcing for simulation state reconstruction
- Analytics on historical simulation data
- Multiple consumers can process the same events differently (e.g., logging + processing)
9. Alternate Exchange for Unroutable Messagesโ
Current Stateโ
Messages sent to non-existent destinations are silently dropped.
Opportunityโ
Alternate exchanges catch unroutable messages and redirect them to a handling queue.
Impactโ
- Error detection for misconfigured routing
- Graceful handling of messages to disconnected clients
- Easier debugging of topology mismatches
10. Headers Exchange for Content-Based Routingโ
Current Stateโ
Routing is based solely on the destination client ID.
Opportunityโ
A headers exchange routes messages based on metadata attributes:
- Message type (control vs. data)
- Payload size category
- Simulation metadata tags
Impactโ
- Content-aware routing without parsing message bodies
- Specialized handlers for different message types
- Load distribution based on message characteristics
11. Connection/Channel Poolingโ
Current Stateโ
Each client creates its own connection with 3 channels (CTRL, SEND, RECV).
Opportunityโ
Connection pooling could reduce overhead when many clients share the same broker.
This was discussed and deliberately not implemented in the initial version due to:
- Difficulty tracking per-client routing over shared connections
- Increased per-message overhead
May be worth revisiting for large-scale simulations.
Impactโ
- Scalability for simulations with many nodes
- Resource efficiency on broker and clients
- Reduced connection setup latency
12. Management API Integrationโ
Current Stateโ
No programmatic visibility into queue depths, message rates, or client status.
Opportunityโ
RabbitMQ's Management HTTP API provides:
- Queue statistics (depth, rates, consumer count)
- Connection and channel monitoring
- Dynamic configuration
Impactโ
- Monitoring dashboard for simulation health
- Dynamic scaling based on queue depth
- Client discovery without daemon tracking
- Alerting on queue buildup or disconnections
13. Lazy Queues for Large Simulationsโ
Current Stateโ
Messages are held in memory, which limits simulation scale for large payloads or many clients.
Opportunityโ
Lazy queues store messages on disk:
- Support millions of messages per queue
- Reduced memory footprint
- Trade-off: slightly higher latency
Impactโ
- Large-scale simulations with many queued messages
- Memory efficiency for resource-constrained environments
- Burst handling without memory exhaustion
Prioritized Recommendationsโ
Short-Term (Low Effort, High Value)โ
- Dead Letter Exchanges โ immediate debugging visibility with minimal code changes
- Publisher Confirms โ improves reliability without major architectural changes
- Consumer Prefetch โ performance improvement with a simple config change
Medium-Termโ
- Topic Exchange โ enables multicast and broadcast patterns
- Message TTL โ built-in latency simulation (pending design decision)
- Management API โ monitoring and observability dashboard
Long-Term Strategicโ
- Streams โ event sourcing and replay capability
- Priority Queues โ QoS simulation support
- Quorum Queues โ high availability for production deployments
Go Deeperโ
- RabbitMQ Backend โ the current implementation these proposals build on
- Contribute โ these proposals are open for community implementation