359 字
2 分钟
如何保证消息队列的高可用性

参考链接#

advanced-java———消息队列

比较 Solace 和 Kafka——Solace

如何保证消息队列的高可用性#

因为我们公司主要用的就是solace,所以我还是主要分析solace和kafka的区别,以便应对面试。

Kafka achieves high availability through partition replication. Each topic partition has one leader and zero or more followers across different brokers. Producers and consumers only interact with the leader, and the followers replicate data from it to ensure redundancy. If a broker fails, a new leader can be elected from the ISR (in-sync replica) set.

However, this architecture comes with tradeoffs. To ensure zero data loss, the producer must wait for acknowledgments from all replicas (acks=all), and unclean leader election must be disabled. If these aren’t configured correctly, Kafka may lose messages during failover or recovery. This means that HA is possible — but not automatic.

Kafka depends on KRaft for metadata coordination and leader election and setting up operational HA requires several

参考solace的官方文档,kafka实现高可用的方式,主要是通过分区副本的方式。每个topic的分区都有一个leader和多个follower,但是生产者和消费者只需要与leader交互即可。follower会从leader复制数据确保redundancy,如果broker失败了,一个新的leader会从ISR集中建立。

然而这个架构来自tradeoffs,为确保没有任何数据丢失,生产者必须等待所有的副本(replicas)已经acknowledged. 并且unclean leader election必须被禁用。 如果配置不正确,kafka在故障转移或者恢复中可能丢失数据。高可用性是可能的,但是不是自动化的。

如何保证消息队列的高可用性
https://iszengmh.pages.dev/posts/如何保证消息队列的高可用性/
作者
Rise Zeng
发布于
2025-10-23
许可协议
CC BY-NC-SA 4.0