Vert.x和Netty有什么区别?

25

Vert.x和Netty有什么区别?为什么会有人更喜欢使用Netty?

它们都是基于事件驱动、非阻塞和异步框架,专门设计用于高负载I/O。

Vert.x基于多反应器模式(Node样式的事件循环在多线程的JVM上),而Netty则使用拦截器链模式。拦截器链模式相对于多反应器模式有哪些优点呢?

我只是快速浏览了一下Netty的文档,但似乎Vert.x比Netty多了一些额外的功能。例如,Vertx是一个独立的服务器,它支持多种语言,提供开箱即用的HA和集群技术。

此外,Vert.x的基准测试略好于Netty。

P.S. 免责声明 - 我非常喜欢Vert.x,并不太熟悉Netty。所以当我问“为什么有人更喜欢使用Netty而不是Vert.x?”时,我只是在尝试比较两者之间的差异。


3
关于相关问题,有一个链接指向一个有趣的阅读材料,涵盖了netty和vertx的一些细节,在tech.kinja.com/上可查看。参考资料请见https://dev59.com/mmAg5IYBdhLWcg3wSpPD - MikeRoger
1个回答

46

不同之处在于Vert.x基于Netty。如果您查看vertx-core中的pom.xml,您会发现:

<!-- We depend on the specific Netty dependencies not netty-all to reduce the size of fatjars -->
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-common</artifactId>
  <version>${netty.version}</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-buffer</artifactId>
  <version>${netty.version}</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-transport</artifactId>
  <version>${netty.version}</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-handler</artifactId>
  <version>${netty.version}</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-handler-proxy</artifactId>
  <version>${netty.version}</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-codec-http</artifactId>
  <version>${netty.version}</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-codec-http2</artifactId>
  <version>${netty.version}</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-resolver</artifactId>
  <version>${netty.version}</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-resolver-dns</artifactId>
  <version>${netty.version}</version>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-core</artifactId>
  <version>${jackson.version}</version>
</dependency>

而针对 Vert.x 3.5.0-SNAPSHOT 的 Netty 版本是:4.1.8.Final

Vert.x 是一个完整的工具包和生态系统,它使用 Netty 作为底层,提供了可插拔模块,用于在 JVM 上构建反应式应用程序。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接