29

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.

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

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

Lii
  • 11,553
  • 8
  • 64
  • 88
Ronald Randon
  • 1,141
  • 3
  • 13
  • 19

2 Answers2

41

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.

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:

  • 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)

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.

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 model that makes sure all the cores are equally used (again, unlike Node.js).

Enjoy!

sscarduzio
  • 5,938
  • 5
  • 42
  • 54
  • Re "_where did you read Vert.x is single threaded?_", Wikipedia (https://en.wikipedia.org/wiki/Vert.x) states that that "_All code is single threaded, freeing from the hassle of multi-threaded programming_". Perhaps I'm missing something but that doesn't seem to be compatible with what you stated in your answer, or with description of Vert.x's Multi-Reactor Pattern that you linked to. Is Wikipedia incorrect, or is their description referring to something else entirely? – skomisa Feb 26 '18 at 06:05
  • 3
    "all code is single threaded" means that no verticle is executed concurrently. But you have many verticles in one application, and many threads in Vert.x. The concurrency model is not very distant from the Actor pattern that you find in Akka and Erlang. – sscarduzio Feb 26 '18 at 14:08
5

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.

belwood
  • 3,320
  • 11
  • 38
  • 45
Michael P
  • 2,017
  • 3
  • 25
  • 33