📜 ⬆️ ⬇️

Vert.x is an asynchronous, event-driven framework created under the influence of node.js. Part 1

Hello!
At the moment, it’s very trendy to use node.js. However, not everyone likes it. In this review, I would like to tell a little about the competitor, which was written under the influence of node.js
Vert.x is an asynchronous, event-driven framework whose goals overlap with the popular node.js. High performance, simple asynchrony and configuration are all vert.x.
The first version of the framework was released in 2012, while node.js was released in 2009. However, it is already supported by VMware and can be run on CloudFoundry.
The main characteristics of the product under the cut:


Interesting? An example of rest helloworld on scala:

class SampleResticle extends Resticle { override def handles = { GET("/hello") :> OK( _ => "world ") } } 


or a simpler server example serving the webroot directory. Groovy example:
 vertx.createHttpServer().requestHandler { req -> def file = req.uri == "/" ? "index.html" : req.uri req.response.sendFile "webroot/$file" }.listen(8080) 

In order to run for example the last helovorld, you need to run:
 vertx run Server.groovy -instances 32 

As you can see everything is extremely simple and clear.
')
Having looked at code examples, and having read the principles, I naturally decided to check the authors' statement about super performance. I looked for comparisons with node.js.
The first graph shows the test results when only 200 / OK responds are given.

The second test gives a 72-byte html page:

tests are taken from here . These tests were conducted relatively long ago. I have materials for more detailed testing. I will tell about it in the third part.
Unfortunately, these tests do not contain scala tests. As is known, scala in many cases turns out to be faster than java.
Perhaps, for the Friday post, this is enough. In the next part I will talk about the basic principles and patterns used in vert.x.
Project site . The link is excellent documentation.

Source: https://habr.com/ru/post/181686/


All Articles