scala Akka 和 Vert.x 的消息传递模型的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21481238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 06:02:34  来源:igfitidea点击:

Difference in message-passing model of Akka and Vert.x

scalaakkavert.x

提问by Bharadwaj

Am a Scala programmer and understand Akka from a developer point of view. I have not looked into Akka library's code. Have read about the two types of actors in the Akka model - thread-based and event-based - but not having run Akka at large scale I dont have experience of configuring Akka for production. And am completely new to Vert.x. So, from the choices perspective to build a reactive application stack I want to know -

我是一名 Scala 程序员,从开发人员的角度理解 Akka。我还没有研究过 Akka 库的代码。已经阅读了 Akka 模型中的两种类型的 actor - 基于线程和基于事件 - 但没有大规模运行 Akka 我没有配置 Akka 用于生产的经验。并且我对 Vert.x 完全陌生。因此,从选择的角度构建我想知道的反应式应用程序堆栈 -

  1. Is the message-passing model of Akka and Vert.x very different? How?
  2. Are the data-structures behind Akka's actors and Vert.x's verticles to buffer messages very different?
  1. Akka 和 Vert.x 的消息传递模型是不是很不一样?如何?
  2. Akka 的 actor 和 Vert.x 的 verticles 背后的数据结构用于缓冲消息是否有很大不同?

回答by clagccs

In a superficial view they're really similar, although I personally consider more similar Vert.x ideas to some MQ system than to Akka... the Vert.x topology is more flat: A verticle share a message with other verticle and receive a response... instead Akka is more like a tree, where you've several actors, but you can supervise actors using other actor,..for simple projects maybe they're not so big deal, but for big projects you could appreciate a more "hierarchic system"...

从表面上看,它们真的很相似,尽管我个人认为 Vert.x 的想法与某些 MQ 系统比与 Akka 更相似……Vert.x 拓扑更扁平:一个顶点与其他顶点共享一条消息并接收一个响应......相反,Akka 更像是一棵树,在那里你有几个演员,但你可以用其他演员监督演员,..对于简单的项目也许它们不是什么大问题,但对于大项目,你可以欣赏更多“等级制度”...

Vert.x on the other hand, offer a better Interoperability between very popular languages*. For me that is a big point, where you would need to mix actors with a MQ system and dealing with more complexity, Vert.x makes it simple and elegant..so the answer, which is better?...depend, if your system will be constructed only over Scala, then Akka could be the best way...if you need communication with JavaScript, Ruby, Python, Java, etc... and don't need a complex hierarchy, then Vert.x is the way to go..

另一方面,Vert.x 在非常流行的语言之间提供更好的互操作性*。对我来说,这是一个重要的点,您需要将 Actor 与 MQ 系统混合并处理更多复杂性,Vert.x 使它变得简单而优雅......所以答案,哪个更好?......取决于,如果你系统将仅在 Scala 上构建,那么 Akka 可能是最好的方法……如果您需要与 JavaScript、Ruby、Python、Java 等通信……并且不需要复杂的层次结构,那么 Vert.x 是要走的路..

*(using JSON, which could be an advantage or disadvantage compared to)

*(使用 JSON,相比之下这可能是一个优势或劣势)

Also you must consider that Vert.x is a full solution, TCP, HTTP server, routing, even WebSocket!!! That is pretty amazing because they offer a full stack and the API is very clean. If you choose Akka you would need use a framework like Play, Xitrum Ospray. Personally I don't like any of them.

另外你必须考虑到 Vert.x 是一个完整的解决方案,TCP、HTTP 服务器、路由,甚至是 WebSocket!!!这非常了不起,因为它们提供了完整的堆栈并且 API 非常干净。如果您选择 Akka,则需要使用 Play、Xitrum Ospray 等框架。就我个人而言,我不喜欢其中任何一个。

Also remember that Vert.x is a not opinionated platform, you can use Akka or Kafka with it, for example, without almost any overhead. The way how every part of the system is decouple inside a verticle makes it so simple.

还要记住,Vert.x 是一个不自以为是的平台,例如,您可以将 Akka 或 Kafka 与它一起使用,几乎没有任何开销。系统的每个部分如何在verticle内部解耦的方式使它变得如此简单。

Vert.x is a big project with an amazing perspective but really new, if you need a solution now maybe it would not be the better option, fortunately you can learn both and use both in the same project.

Vert.x 是一个具有惊人视角的大项目,但确实很新,如果您现在需要一个解决方案,也许它不是更好的选择,幸运的是,您可以在同一个项目中学习并使用两者。

回答by tuxdna

After doing a bit of google search I have figured that at detailed comparison of Akka vs Vert.x has not yet been done ( atleast I cound't find it ).

在做了一些谷歌搜索之后,我发现 Akka 与 Vert.x 的详细比较尚未完成(至少我找不到)。

Computation model:

计算模型:

  • Vert.x is based on Event Driven model.
  • Akka is based on Actor Model of concurrency,
  • Vert.x 基于事件驱动模型。
  • Akka基于并发的Actor Model,

Reactive Streams:

反应流:

  • Vert.x has Reactive Streams builtin
  • Akka supports Reactive Streams via Akka Streaming. Akka has stream operators ( via Scala DSL ) that is very concise and clean.
  • Vert.x 内置了 Reactive Streams
  • Akka 通过 Akka Streaming 支持 Reactive Streams。Akka 具有非常简洁和干净的流操作符(通过 Scala DSL)。

HTTP Support

HTTP 支持

  • Vert.x has builtin support of creating network services ( HTTP, TCP etc )
  • Akka has Akka HTTP for that
  • Vert.x 内置支持创建网络服务(HTTP、TCP 等)
  • Akka为此提供了Akka HTTP

Scala support

Scala 支持

  • Vert.x is written in Java
  • Akka is written in Scala and its fun to work on
  • Vert.x 是用 Java 编写的
  • Akka 是用 Scala 编写的,工作起来很有趣

Remote services

远程服务

  • Vert.x supports services, so we need to explicitly create services
  • Akka has Actors which can be deployed anywhere on the network, with support for clustering, replication, load-balancing, supervision etc.
  • Vert.x 支持服务,所以我们需要显式创建服务
  • Akka 拥有可以部署在网络任何地方的 Actor,支持集群、复制、负载平衡、监督等。

References:

参考: