Java Tomcat 与 Vert.x

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23925968/
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-08-14 09:07:13  来源:igfitidea点击:

Tomcat vs Vert.x

javatomcatwebserververt.x

提问by Ronald Randon

For the past few days I have been reading Vert.x documents. I know that Vert.x is polyglot, single threaded, non-blocking IO, modular architecture, high scalability.

过去几天我一直在阅读 Vert.x 文档。我知道 Vert.x 是多语言、单线程、非阻塞 IO、模块化架构、高扩展性。

Is there any other major differences between tomcat and Vert.x?

tomcat 和 Vert.x 之间还有其他主要区别吗?

Also when we should use tomcat and when to use Vert.x?

另外我们什么时候应该使用tomcat,什么时候使用Vert.x?

采纳答案by sscarduzio

Tomcat is a servlet container, so it offers you a platform that helps you to develop and deploy HTTP based applications like web sites or web services.

Tomcat 是一个 servlet 容器,因此它为您提供了一个平台,可帮助您开发和部署基于 HTTP 的应用程序,如网站或 Web 服务。

Vert.x instead helps you to develop and deploy any kind of asynchronous applications. It's true that modern versions of Tomcat support asynchronous servlets, but Vert.x comes with a far larger amount of user friendly asynchronous APIs plus other goodness:

相反,Vert.x 可以帮助您开发和部署任何类型的异步应用程序。的确,现代版本的 Tomcat 支持异步 servlet,但 Vert.x 附带了大量用户友好的异步 API 以及其他优点:

  • Complete Filesystem asynchronous API
  • TCP (server and client)
  • UDP (server and client)
  • HTTP(S) (server and client)
  • Shared data service (share objects between polyglot modules)
  • HA and Clustering
  • Cluster-wide messaging (event loop)
  • Event bus bridge (the extension of the event loop to browsers via SockJS)
  • A growing ecosystem of Vert.x modules
  • Possibility to embed Vert.x in legacy code
  • Leveraging the existing rich and solid ecosystem of Java libraries (Vert.x runs on the JVM, unlike Node.js)
  • 完整的文件系统异步 API
  • TCP(服务器和客户端)
  • UDP(服务器和客户端)
  • HTTP(S)(服务器和客户端)
  • 共享数据服务(在多语言模块之间共享对象)
  • HA 和集群
  • 集群范围的消息传递(事件循环)
  • 事件总线桥(通过 SockJS 将事件循环扩展到浏览器)
  • 不断增长的 Vert.x 模块生态系统
  • 在遗留代码中嵌入 Vert.x 的可能性
  • 利用现有的丰富而可靠的 Java 库生态系统(Vert.x 在 JVM 上运行,与 Node.js 不同)

Personally I think learning Vert.x is very useful. At work I reused the same knowledge with great success to realise three very different products: a zero-copy ultrafast Redis proxy, a JPA-backed REST API, and a reactive single-page web application.

我个人认为学习 Vert.x 非常有用。在工作中,我成功地重用了相同的知识,实现了三种截然不同的产品:零拷贝超快 Redis 代理、JPA 支持的 REST API 和反应式单页 Web 应用程序。

Have a look at the example code, it's pretty straight forward and the boilerplate is close to zero.

看看示例代码,它非常简单,样板代码接近于零。

One more thing: where did you read Vert.x is single threaded? It's not true! Vert.x has a very neat concurrency modelthat makes sure all the cores are equally used (again, unlike Node.js).

还有一件事:你在哪里读到 Vert.x 是单线程的?这不是真的!Vert.x 有一个非常简洁的并发模型,可确保所有内核都得到同等使用(同样,与 Node.js 不同)。

Enjoy!

享受!

回答by Michael P

Vert.x HTTP server allows to you listen to many ports in the same time. Also, its concurrency model is much better than any thread pool based approach if you want to combine your HTTP server with http client or anything else. Its performance is much better as well.

Vert.x HTTP 服务器允许您同时侦听多个端口。此外,如果您想将 HTTP 服务器与 http 客户端或其他任何东西结合起来,它的并发模型比任何基于线程池的方法都要好得多。它的性能也好得多。