exactly-once 和 at-least-once 保证之间的区别
difference between exactly-once and at-least-once guarantees
我在研究分布式系统,参考这个老问题:Whosebug link
我真的无法理解恰好一次、至少一次和最多一次保证之间的区别,我也在 Kafka、Flink 和 Storm 和 Cassandra 中阅读了这些概念。例如有人说 Flink 更好,因为它有精确一次保证,而 Storm 只有至少一次。
我知道 exactly-once 模式在延迟方面更好,但同时在容错方面更差,对吗?如果我没有重复项,如何恢复流?然后...如果这是一个真正的问题,为什么 exactly-once 保证比其他保证更好?
谁能给我更好的定义?
Here 是一篇 激进的 文章,值得一读。
我会尽量回答你的问题:
- Exact-once 在大型分布式系统中不能容错,
因为所有系统不可能就每条消息达成一致,如果
一些系统可能会失败。您可以执行 exact 一次,但它会
通过您自己的代价高昂的协调,至少控制一次。思考
关于 TCP 在底层 IP 时如何确保可靠的数据传输
协议不可靠。
- 通过在至少一次的基础上实施精确一次,您将拥有重复项(如果不是精确的)以防万一,您需要的是去重。
- Exact-once 并没有被认为更好,因为它的成本很高,而 at-least-once 在大多数情况下就足够了。
以下定义引用自 Akka 文档
最多一次 交付
means that for each message handed to the mechanism, that message is
delivered zero or one times; in more casual terms it means that
messages may be lost.
至少一次 交付
means that for each message handed to the mechanism potentially
multiple attempts are made at delivering it, such that at least one
succeeds; again, in more casual terms this means that messages may be
duplicated but not lost.
恰好一次 交付
means that for each message handed to the mechanism exactly one
delivery is made to the recipient; the message can neither be lost nor
duplicated.
第一个是最便宜的——性能最高,实现开销最少——因为它可以以即发即弃的方式完成,而无需在发送端或传输机制中保持状态。第二个需要重试以应对传输丢失,这意味着在发送端保持状态并在接收端具有确认机制。第三个是最昂贵的——因此性能最差——因为除了第二个之外,它还需要在接收端保留状态以过滤掉重复的交付
Flink 使用这些术语来谈论事件对应用程序状态的影响。假设我试图在每天 windows 中使用标签 apache-flink 将 post 计数到 Whosebug。如果我使用 exactly once 保证,那么每个 post 都将只计算一次并且我的分析将 100% 正确,即使过程中出现故障和一些必须重新处理数据才能实现这一目标。 Flink 通过结合全局一致的快照和流重放来实现这一点。使用 至少一次 ,然后如果出现故障,一些 post 可能会被计算两次,但我保证每个 post 都会被管道分析.并且at most once不会有快照,也不会在发生故障时重放,如果出现问题,这将导致少计posts。
Exactly-once 在正确性和容错性方面是最优的,但以增加一点延迟为代价。
有关此主题的更深入的处理,请参阅来自 data Artisans 的博客 post -- High-throughput, low-latency, and exactly-once stream processing with Apache Flink™ -- and the documentation of Flink's internals。
我找到了一个很棒的网站,其中所有(或大部分)Cloud Computing Patterns
都得到了简洁的讨论。真心推荐给大家,看看:http://www.cloudcomputingpatterns.org
恰好一次交付
For many critical systems duplicate messages are inacceptable. The
messaging system ensures that each message is delivered exactly once
by filtering possible message duplicates automatically.
至少发送一次
In case of failures that lead to message loss or take too long to
recover from, messages are retransmitted to assure they are delivered
at least once.
我在研究分布式系统,参考这个老问题:Whosebug link
我真的无法理解恰好一次、至少一次和最多一次保证之间的区别,我也在 Kafka、Flink 和 Storm 和 Cassandra 中阅读了这些概念。例如有人说 Flink 更好,因为它有精确一次保证,而 Storm 只有至少一次。
我知道 exactly-once 模式在延迟方面更好,但同时在容错方面更差,对吗?如果我没有重复项,如何恢复流?然后...如果这是一个真正的问题,为什么 exactly-once 保证比其他保证更好?
谁能给我更好的定义?
Here 是一篇 激进的 文章,值得一读。
我会尽量回答你的问题:
- Exact-once 在大型分布式系统中不能容错, 因为所有系统不可能就每条消息达成一致,如果 一些系统可能会失败。您可以执行 exact 一次,但它会 通过您自己的代价高昂的协调,至少控制一次。思考 关于 TCP 在底层 IP 时如何确保可靠的数据传输 协议不可靠。
- 通过在至少一次的基础上实施精确一次,您将拥有重复项(如果不是精确的)以防万一,您需要的是去重。
- Exact-once 并没有被认为更好,因为它的成本很高,而 at-least-once 在大多数情况下就足够了。
以下定义引用自 Akka 文档
最多一次 交付
means that for each message handed to the mechanism, that message is delivered zero or one times; in more casual terms it means that messages may be lost.
至少一次 交付
means that for each message handed to the mechanism potentially multiple attempts are made at delivering it, such that at least one succeeds; again, in more casual terms this means that messages may be duplicated but not lost.
恰好一次 交付
means that for each message handed to the mechanism exactly one delivery is made to the recipient; the message can neither be lost nor duplicated.
第一个是最便宜的——性能最高,实现开销最少——因为它可以以即发即弃的方式完成,而无需在发送端或传输机制中保持状态。第二个需要重试以应对传输丢失,这意味着在发送端保持状态并在接收端具有确认机制。第三个是最昂贵的——因此性能最差——因为除了第二个之外,它还需要在接收端保留状态以过滤掉重复的交付
Flink 使用这些术语来谈论事件对应用程序状态的影响。假设我试图在每天 windows 中使用标签 apache-flink 将 post 计数到 Whosebug。如果我使用 exactly once 保证,那么每个 post 都将只计算一次并且我的分析将 100% 正确,即使过程中出现故障和一些必须重新处理数据才能实现这一目标。 Flink 通过结合全局一致的快照和流重放来实现这一点。使用 至少一次 ,然后如果出现故障,一些 post 可能会被计算两次,但我保证每个 post 都会被管道分析.并且at most once不会有快照,也不会在发生故障时重放,如果出现问题,这将导致少计posts。
Exactly-once 在正确性和容错性方面是最优的,但以增加一点延迟为代价。
有关此主题的更深入的处理,请参阅来自 data Artisans 的博客 post -- High-throughput, low-latency, and exactly-once stream processing with Apache Flink™ -- and the documentation of Flink's internals。
我找到了一个很棒的网站,其中所有(或大部分)Cloud Computing Patterns
都得到了简洁的讨论。真心推荐给大家,看看:http://www.cloudcomputingpatterns.org
恰好一次交付
For many critical systems duplicate messages are inacceptable. The messaging system ensures that each message is delivered exactly once by filtering possible message duplicates automatically.
至少发送一次
In case of failures that lead to message loss or take too long to recover from, messages are retransmitted to assure they are delivered at least once.