The architecture, design and development of RabbitMQ based computer systems has, up until now, habitually been carried out in an ad-hoc and informal manner. This leads to design misses during the early system development phases, which later manifest as various problems in performance on live RabbitMQ installations. In this talk Ayanda Dube introduces and discusses a structured approach/guide to designing and implementing systems which make use of RabbitMQ as a messaging and queueing engine. We get into the depths of each design phase and points of consideration which aid system developers and solution architects in implementing robust, reliable and stable engineered systems which, under the hood, make use of RabbitMQ, for simple requirements, to some of the most complex deployments and use cases.
3. www.erlang-solutions.com
FABRIC DESIGN : DEFINITIONS
▸ Fabric is/are the internal (user-defined/created) elements within
a RabbitMQ instance
▸ Queues, Exchanges, Bindings, Policies, Parameters, Connections,
Channels, etc, internal to the broker
▸ Fabric design entails structuring all internal elements to precisely
meet/match your requirement
▸ Direct impact on overall performance
▸ Direct impact on overall resource utilization
RabbitMQ Node
Q1
Ex1
Q2
Q3
RK-1
RK-2
RK-3
4. www.erlang-solutions.com
FABRIC DESIGN : CONTROL
▸ Any interface that directly alters the internal structure of your
RabbitMQ instance
▸ Standard/built-in interfaces are:
▹ Configuration file(s)
▹ CLI
▹ Client Applications (AMQP, MQTT, STOMP, etc)
▹ Management UI/API
▹ Plugins
8. www.erlang-solutions.com
FABRIC DESIGN : THROUGHPUT
▸ Achieve highest attainable - 100% ideally!
▸ Efficiently!
▸ Some guarantees of high throughput come at a cost!
▸ e.g. Using transactions, longer TCP buffer sizes, etc
▸ Predictions i.e. model your solution (e.g. based on predicted
consumer-producer ratios)
▸ Run performance tests
▸ Capture results
▹ Observations
▹ Draw conclusions on design
▸ Deduce final design approximations based on quantitative
estimate results
13. www.erlang-solutions.com
FABRIC DESIGN : THROUGHPUT
My system model approaches 500% consumer-producer ratio
Message payloads less than 1KB
100% throughput attainable at 10KiB sendbuf/recvbuf
▸ Conclude on “near precise” configuration
15. www.erlang-solutions.com
FABRIC DESIGN : MEMORY
▸ High performance while conserving memory as much as possible
▸ Consequences & impact:
▹ Service
▹ Node terminations
▸ How much memory do I allocate for each node?
▸ Considerations from fabric element
▹ Node
▹ Queues
▹ Connections
▸ Precise RabbitMQ version selection (resolved memory leaks)
▸ Simulate extreme conditions
17. www.erlang-solutions.com
FABRIC DESIGN : MEMORY
▸ Queues
▸ Consider worst case scenario - all queues on single node
1. Define a queue (varying types depending on use-case)
2. Publish max-number of anticipated messages
3. Capture/compare “rabbitmqctl list_queues name memory” = M
4. QueueMemoryLimit = M x ApproximateMaxCount
Total Max-Approximate Queue Memory
18. www.erlang-solutions.com
FABRIC DESIGN : MEMORY
▸ Connections
▸ Consider worst case scenario - send/recv buffers full
▸ Consumers - assume sendbuf MAX ( e.g. + ~½ or ALL, confirming
in recvbuf)
▸ Producers - assume recvbuf MAX (~⅓ sendbuf for
confirmations)
▸ Add socket reader memory
▸ And more elements if possible
19. www.erlang-solutions.com
FABRIC DESIGN : MEMORY
1. Default 192KiB sendbuf/recvbuf
2. MaxConsumerConnMemory = (192KiB + 62KiB) x N consumers
3. MaxProducerConnMemory = 192KiB x N producers
4. MaxSocketReaderMemory Approximation x Total Connections
Total Max-Approximate Connection Memory
ACKs
20. www.erlang-solutions.com
FABRIC DESIGN : MEMORY
Total Max-Approximate Queue Memory
Total Max-Approximate Connection Memory
Total Max-Approximate Live Node Memory Utilization
Standalone Node Memory
21. www.erlang-solutions.com
FABRIC DESIGN : MEMORY
▸ Defined queue types to be used (e.g. lazy?)
▸ Purchase appropriate server
▸ Define precise configurations
▹ VM High watermark limits
▹ VM High watermark paging ratio
▸ Same can be done for DISK durable fabric and persistent
messages
▸ And more …
23. www.erlang-solutions.com
FABRIC DESIGN : LATENCY
▸ Speed of traversal/message propagation time through fabric
▸ Main hindrances:
▹ Head of Line Blocking (HOL)
▹ Routing inefficiencies
▹ *Disk I/O
▹ *Topology Related (Mirroring, no of replicas, ),
RabbitMQ Node
Q1
Ex1
Q2
Q3
RK-1
RK-2
RK-2
P1 C1
LATENCY
28. www.erlang-solutions.com
▸ User friendliness (support)
▸ Fabric state evolves and gets more complex
▸ Maintaining and monitoring can become a nightmare if, no
conventions were followed
▸ Designing fabric to be as easy to maintain and possible
▹ Naming conventions
▹ Policies
▹ Consistent bindings
▹ Precise use of exchanges
▹ Partitioning business logic by VHOST
FABRIC DESIGN : ERGONOMICS