6
votes

I recently tested a simple HTTP server using vert.x( java based) I was amazed by the throughput and api latency of http server, it is blazingly fast.

The same piece of code of http-server was run on java application with single thread, lock free and non-blocking. Performance was less than 1/3rd of vert.x one.

What I do not understand is, what is the core technical difference that the vert.x outperforms non-reactive java application ?

STATS :

Testing was done using Jmeter. Both jmeter and application was run on same machine- jmeter consuming cpu 25-50%, app consuming cpu 20-30% . All the tests were run for 5 minutes.

  1. Spring boot with 1 tomcat worker thread :

Jmeter with 1 client thread bombarding request (throughout :3474 per sec): enter image description here

Jmeter with 50 client thread bombarding request concurrently (throughout :4285 per sec): enter image description here

  1. Vert.x ( java based ) with only 1 vertical ( http processor vertical ) – meaning only 1 processor thread

Jmeter with 1 client thread bombarding request (throughout :9382 per sec) : enter image description here

Jmeter with 50 client threads bombarding requests concurrently (throughout :20785 per sec): enter image description here

1
Profile both the apps and look at the thread dump. That will get give a clue. You will need to provide numbers to get feedback. - randominstanceOfLivingThing

1 Answers

6
votes

There are many reasons for that.
First one is that you compare single threaded bare Java application with Vertx, which is actually multithreaded.
Second one is how you use lock free data structures. Lock free doesn't necessarily means "faster in all conditions".
Third, and I think that's the main point, some of the best Red Hat developers contributed to Vertx development. You can examine the source code and see some very smart use of buffers, for example. It's a bit too much to expect from a example project to outperform such a framework from the first shot. If you're interested in some alternatives, check Rapidoid performance, which should be on par with Vertx.