简体   繁体   English

Akka: - 为什么不能保证消息到达(发送后)? 消息的失败率是多少?

[英]Akka: - why is it that messages are not guaranteed to arrive (after being send)? What is the failure rate for messages?

It says in the documentation that akka has "at-most once delivery", and that messages are not guaranteed to arrive at destination.它在文档中说 akka 具有“最多一次交付”,并且不能保证消息到达目的地。

What is the reason for this behavior?这种行为的原因是什么? What happens to the messages which are not delivered?未传递的消息会怎样? Are they considered lost?他们被认为是丢失了吗?

Edit: I forgot the most important part.编辑:我忘记了最重要的部分。 Is there a rate of loss I can refer to?有没有我可以参考的损失率? Do you know how pessimistic I have to be as regards message delivery guarantee (like is there % rate of failures?).. Just because I have a cluster of actors, and they will be running on the same web-server, and I don't know If I should be thinking if message failures will be 1 in 5, or 1 in 100.你知道我对消息传递保证有多悲观吗(比如失败率是多少?)。仅仅因为我有一群演员,他们将在同一个网络服务器上运行,我不知道不知道我是否应该考虑消息失败的概率是 5 分之一还是 100 分之一。

So, Akka actually offers both options of "at-most once delivery" and guaranteed delivery aka "at least once delivery".因此,Akka 实际上提供了“最多一次交付”和“至少一次交付”的保证交付选项。 See the link user1234 posted in the comments for a good introduction into the concepts of "at least once" vs "at most once".请参阅评论中发布的链接 user1234 ,以很好地介绍“至少一次”与“最多一次”的概念。

So Akka can do either option.所以 Akka 可以做任何一个选择。 Why is "at most once" the default?为什么“最多一次”是默认设置?

The short answer to your question is that switching to guaranteed delivery has at least five very significant costs:对您的问题的简短回答是,切换到保证交付至少有五个非常重要的成本:

  • Guaranteed delivery in a distributed system requires persistence (otherwise you can't guarantee delivery in case of node failure).分布式系统中的保证交付需要持久性(否则在节点故障的情况下无法保证交付)。 This introduces an enormous performance overhead, however.然而,这会带来巨大的性能开销。

  • Guaranteed delivery in a distributed system introduces the chance of duplicate deliveries.分布式系统中的保证交付引入了重复交付的机会。 (If you can't confirm delivery, fundamentally the only thing you can do is retry, introducing potential duplicates). (如果您无法确认交付,基本上您唯一能做的就是重试,引入潜在的重复项)。 For some applications this is problematic.对于某些应用程序,这是有问题的。 (You can resolve this with de-duping, but this introduces additional overhead and is generally easier to do in application code.) Thus the term "at least once". (您可以通过重复数据删除来解决这个问题,但这会引入额外的开销,并且通常在应用程序代码中更容易做到。)因此术语“至少一次”。

  • Guaranteed delivery can also affect message order.保证传递也会影响消息顺序。 eg you can either wait for each acknowledgement before attempting the next (which would be insanely slow) or you can deliver retries out of order.例如,您可以在尝试下一个确认之前等待每个确认(这会非常慢),或者您可以不按顺序进行重试。 Which, for many applications, can be problematic.对于许多应用程序来说,这可能是有问题的。

  • Guaranteed delivery just has a lot more overhead.保证交付只是有更多的开销。 This includes both the bookkeeping necessary, the memory to basically keep messages around longer, and also the network chatter of acknowledgements.这包括必要的簿记、基本保持消息更长时间的内存,以及确认的网络喋喋不休。

  • Guaranteed delivery also requires persistence, as noted above.如上所述,保证交付还需要持久性。 But not only does this add overhead as already mentioned, but this just also adds complexity.但这不仅增加了前面提到的开销,而且还增加了复杂性。 Especially since this generally means centralized storage if you want to handle failed nodes well and/or expanding/contracting clusters.特别是因为如果您想很好地处理故障节点和/或扩展/收缩集群,这通常意味着集中存储。

So, Akka gives you the choice.因此,Akka 为您提供了选择。 But it also cautions you (in that doc) that for most applications it is much easier to handle message delivery failures via application code than by relying on guaranteed delivery.但它也提醒您(在该文档中),对于大多数应用程序,通过应用程序代码处理消息传递失败比依赖保证传递容易得多。 (Both for performance reasons and because guaranteed delivery introduces its own problems like duplicates and out of order messages.) (出于性能原因,也因为有保证的交付会引入其自身的问题,例如重复和乱序消息。)

EDIT: In response to the follow up on how reliable "at most once" messaging is, it's hard to give an exact answer.编辑:为了回应关于“最多一次”消息传递有多可靠的后续行动,很难给出确切的答案。 The key thing to understand is that it's not as if the messaging protocol is inherently unreliable.需要理解的关键是,消息协议并不是天生不可靠的。 If your hardware is 100% reliable and your network is 100% reliable and your software is 100% reliable, then your messages will be delivered 100% of the time.如果您的硬件 100% 可靠,您的网络 100% 可靠,您的软件 100% 可靠,那么您的消息将在 100% 的时间内送达。 But if your network is down then you will lose 100% of your messages.但是,如果您的网络出现故障,那么您将丢失 100% 的消息。 If your destination server crashed due to an NPE, you will lose 100% your messages.如果您的目标服务器因 NPE 而崩溃,您将 100% 丢失消息。

Under normal circumstances all messages will arrive.在正常情况下,所有消息都会到达。 The only question is how often you experience abnormal circumstances.唯一的问题是您遇到异常情况的频率。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM