Kafka docs Producer可能的消息丢失
Kafka docs Producer possible message loss
我目前正在了解有关 Kafka Producer 的更多信息。我对文档中的以下段落感到有些困惑:
Messages written to the partition leader are not immediately readable
by consumers regardless of the producer’s acknowledgement settings.
When all in-sync replicas have acknowledged the write, then the
message is considered committed, which makes it available for reading.
This ensures that messages cannot be lost by a broker failure after
they have already been read. Note that this implies that messages
which were acknowledged by the leader only (that is, acks=1) can be
lost if the partition leader fails before the replicas have copied the
message. Nevertheless, this is often a reasonable compromise in
practice to ensure durability in most cases while not impacting
throughput too significantly.
我对此的解释是,消息可能会在领导者和复制代理之间的同步过程中丢失,即消息不会被提交,除非它们已被成功复制。
我不明白(例如)Java 应用程序如何防止此消息丢失。
它在 'only-leader' 和完整复制之间是否收到不同的确认?
this is often a reasonable compromise in practice
怎么样?他们是否假设您应该记录失败的消息并手动将它们重新排队?或者它是如何工作的?
"Does it receive different acknowledgements between 'only-leader' and the full replication?"
领导者和副本确认之间没有区别。您只能通过其配置 acks
来控制生产者的行为。如果它被设置为 1
它只会等待领导者确认,如果你将它设置为 all
它会在生产者考虑写入之前等待所有副本(基于主题的复制因子)消息成功。
如果你设置了acks=all
并且领导者和副本之间的同步失败,你的生产者将收到一个可重试异常(“NotEnoughReplicasException”或“NotEnoughReplicasAfterAppendException”,参见更多详细信息 )。基于生产者配置 retries
它将尝试重新发送消息。 Kafka 的构建方式是希望崩溃的代理再次可用(在“短”时间内)。
如果您设置了 acks=1
并且领导者和副本之间的同步失败,您的生产者认为消息已成功写入集群,并且不会尝试复制消息。当然领导者会继续将消息复制到它的副本。但并不能真正保证这会发生。在消息被复制之前,leader broker 本身可能会出现问题,导致消息永远丢失。
我目前正在了解有关 Kafka Producer 的更多信息。我对文档中的以下段落感到有些困惑:
Messages written to the partition leader are not immediately readable by consumers regardless of the producer’s acknowledgement settings. When all in-sync replicas have acknowledged the write, then the message is considered committed, which makes it available for reading. This ensures that messages cannot be lost by a broker failure after they have already been read. Note that this implies that messages which were acknowledged by the leader only (that is, acks=1) can be lost if the partition leader fails before the replicas have copied the message. Nevertheless, this is often a reasonable compromise in practice to ensure durability in most cases while not impacting throughput too significantly.
我对此的解释是,消息可能会在领导者和复制代理之间的同步过程中丢失,即消息不会被提交,除非它们已被成功复制。
我不明白(例如)Java 应用程序如何防止此消息丢失。 它在 'only-leader' 和完整复制之间是否收到不同的确认?
this is often a reasonable compromise in practice
怎么样?他们是否假设您应该记录失败的消息并手动将它们重新排队?或者它是如何工作的?
"Does it receive different acknowledgements between 'only-leader' and the full replication?"
领导者和副本确认之间没有区别。您只能通过其配置 acks
来控制生产者的行为。如果它被设置为 1
它只会等待领导者确认,如果你将它设置为 all
它会在生产者考虑写入之前等待所有副本(基于主题的复制因子)消息成功。
如果你设置了acks=all
并且领导者和副本之间的同步失败,你的生产者将收到一个可重试异常(“NotEnoughReplicasException”或“NotEnoughReplicasAfterAppendException”,参见更多详细信息 retries
它将尝试重新发送消息。 Kafka 的构建方式是希望崩溃的代理再次可用(在“短”时间内)。
如果您设置了 acks=1
并且领导者和副本之间的同步失败,您的生产者认为消息已成功写入集群,并且不会尝试复制消息。当然领导者会继续将消息复制到它的副本。但并不能真正保证这会发生。在消息被复制之前,leader broker 本身可能会出现问题,导致消息永远丢失。