jooby-project / jooby

The modular web framework for Java and Kotlin
https://jooby.io
Apache License 2.0
1.71k stars 197 forks source link

Performance compared to Light-4j #1399

Closed raderio closed 5 years ago

raderio commented 5 years ago

Here https://github.com/networknt/microservices-framework-benchmark we can notice that Light-4j is more faster than Jooby, does someone investigated what are the reasons?

agentgt commented 5 years ago

Go look at the code. They are not really doing routing you would do in the real world for any reasonable microservice that would normally be doing URI templates.

Also you can see here in the Techempower Jooby2 is outperforming light4j but I'm guessing that is an older version of light4j.

https://www.techempower.com/benchmarks/#section=data-r18&hw=ph&test=plaintext

Anyway I played around these HTTP server benchmarks using raw undertow and there are tons of ways you can cheat the testing.

One of them is using zero allocation techniques and making routing as simple as possible and in this case that is probably what light4j is doing as this looks like it will accept everything:

https://github.com/networknt/microservices-framework-benchmark/blob/master/light-4j/src/main/java/Example.java#L13

        .addPrefixPath("/", new HttpHandler() {

I bet that routing just accepts everything. e.g. "/crapola" would probably route and thus zero routing logic is being done.

compare to Jooby2s https://github.com/networknt/microservices-framework-benchmark/blob/master/jooby-2.x/src/main/java/example/App.java#L9

However it is an interesting question if Jooby has a route everything option and thus bypass the radix tree jooby is using but then you might as well not use a framework!

jknack commented 5 years ago

Adam is right. Also, that benchmark is for 1.x...I sent the pull with 2.x but wasn't merge it.

The techempower benchmark is more reliable and the difference between light4j and jooby 1.x was bc we didn't allow to run code in the event loop thread. Jooby 2 allowed it

jknack commented 5 years ago

just look at the repository and the results you see there are for Jooby 1.x. They weren't updated to 2.x.

Check the techempower site: https://www.techempower.com/benchmarks/#section=test&runid=aa3d1cda-5cb6-489f-bd01-1e3718ca4d8e&hw=ph&test=fortune&l=xan9tr-v