On https://www.rabbitmq.com/ha.html I read about these two properties:

  • ha-promote-on-shutdown
  • ha-promote-on-failure

But I can't find any definition about these. What are the main differences between these two properties? When are they applied? And how should I configure it to achieve Consistency over Availability (CAP theorem)?

1 Answers

1
bumblebee On Best Solutions

What are the main differences between these two properties?

The difference between the two is that the latter can occur with various reasons such as node restart, network failure, etc. They both have different triggering points. ha-promote-on failure is triggered when the node fails, loses connection or is removed from the cluster.ha-promote-on-shutdown is triggered when the node is shutdown gracefully.

When are they applied?

When a queue master node fails, RabbitMQ provides an option to promote a node containing the queue as the master queue node. How this promotion is to be done is configured using the ha-promote-on failure or ha-promote-on-shutdown arguments.

  1. always: When the argument is set to always, any one of the nodes containing the queue will be elected as the master. With this option, there is a possibility that the queues may not be synchronised and you may lose messages.

  2. when-synced: When the argument is set to when-synced, the node is which is synchronous with the master queue node will be selected. Here you can be sure that the selected node will contain the messages the same as the master node. But it has a downside. If none of the queues is in sync with the master, no node will be selected.

By default ha-promote-on-shutdown is set to when-synced and ha-promote-on-failure is set to always.

And how should I configure it to achieve Consistency over Availability (CAP theorem)?

For Consistency, use when-synced; For Availability, use always

Reference - https://www.rabbitmq.com/ha.html#promoting-unsynchronised-mirrors