Core: Adonis performance

Created on 20 Jun 2017  路  10Comments  路  Source: adonisjs/core

This article https://raygun.com/blog/node-js-performance-2017/ shows that Adonis performance is not good as compare to Express on Digital Ocean VM. Is there any other performance test result available.

Most helpful comment

@ansarizafar First of all I don't get into benchmarking wars much and below are the reasons why?

NOTE: Before I share my reasons, Adonis 4.0 is thrice as fast as Adonis 3.2

I am happy that AdonisJs performed better than SailsJs.

The AdonisJs default project makes use of over 4 middleware ( https://github.com/PlainSight/NodeRestPerfTest3/blob/master/yardstick-changes/app/Http/kernel.js ), for sessions, body parsing, flash messages and CORS etc. So the performance will vary since ExpressJs is a bare bone server.

Why I Hate Benchmarking Across Frameworks

Benchmarking with itself is a good idea since you can see if are doing something bad in the newer version.

Also benchmarking different approaches to do one 1 thing is also fine. For example: Benchmarking regex match vs tokenising string intro characters and matching them inside a while loop.

I recently tested Adonis4.0 and Express ( both barebones ) and following are the results.

ExpressJs
Requests per second: 11695.59 [#/sec] (mean)

Adonis 4.0
Requests per second: 9870.53 [#/sec] (mean)

Does this mean AdonisJs is slower?
I don't think so, returning hello world from Express and AdonisJs takes around 4-6ms ( when visited via browser ). What we need to understand here is how Node.js or V8 works internally and what are factors which can change benchmarking results.

  1. AdonisJs supports Controllers and route closures, and whereas ExpressJs only works with closures.

  2. Adonis middleware can also be Es6 classes, whereas with Express, it's again a closure.

  3. AdonisJs routes can be have different middleware, with Express it's all about a chain of functions.

  4. AdonisJs allow subdomains to be binded to routes, so it has to run additional checks to see if host and domain for a route matches.

When doing all these extra operations, v8 has to do little more work and when 1000 of requests are hitting the server every sec, the v8 garbage collector get's less chance to cleanup things and hence the results vary.

The idea is same if you run a raw Node.js HTTP server and benchmark it against express, you will find Express slower, but what express can offer you, raw HTTP server cannot.

In same way what AdonisJs can offer you, Express cannot.

What to do?

When benchmarking speed, you should have a threshold over comparing things. A decent benchmark can be that all of my endpoints will response within 80ms. Now if it is 75ms or 70ms that hardly matters.

In same way Porsche and Ferrari both are fast, it's upto your liking on what you need and what has more value to you.

Also it is easier to add a new server, then to find a new developer and work on complex codebase.

All 10 comments

@ansarizafar First of all I don't get into benchmarking wars much and below are the reasons why?

NOTE: Before I share my reasons, Adonis 4.0 is thrice as fast as Adonis 3.2

I am happy that AdonisJs performed better than SailsJs.

The AdonisJs default project makes use of over 4 middleware ( https://github.com/PlainSight/NodeRestPerfTest3/blob/master/yardstick-changes/app/Http/kernel.js ), for sessions, body parsing, flash messages and CORS etc. So the performance will vary since ExpressJs is a bare bone server.

Why I Hate Benchmarking Across Frameworks

Benchmarking with itself is a good idea since you can see if are doing something bad in the newer version.

Also benchmarking different approaches to do one 1 thing is also fine. For example: Benchmarking regex match vs tokenising string intro characters and matching them inside a while loop.

I recently tested Adonis4.0 and Express ( both barebones ) and following are the results.

ExpressJs
Requests per second: 11695.59 [#/sec] (mean)

Adonis 4.0
Requests per second: 9870.53 [#/sec] (mean)

Does this mean AdonisJs is slower?
I don't think so, returning hello world from Express and AdonisJs takes around 4-6ms ( when visited via browser ). What we need to understand here is how Node.js or V8 works internally and what are factors which can change benchmarking results.

  1. AdonisJs supports Controllers and route closures, and whereas ExpressJs only works with closures.

  2. Adonis middleware can also be Es6 classes, whereas with Express, it's again a closure.

  3. AdonisJs routes can be have different middleware, with Express it's all about a chain of functions.

  4. AdonisJs allow subdomains to be binded to routes, so it has to run additional checks to see if host and domain for a route matches.

When doing all these extra operations, v8 has to do little more work and when 1000 of requests are hitting the server every sec, the v8 garbage collector get's less chance to cleanup things and hence the results vary.

The idea is same if you run a raw Node.js HTTP server and benchmark it against express, you will find Express slower, but what express can offer you, raw HTTP server cannot.

In same way what AdonisJs can offer you, Express cannot.

What to do?

When benchmarking speed, you should have a threshold over comparing things. A decent benchmark can be that all of my endpoints will response within 80ms. Now if it is 75ms or 70ms that hardly matters.

In same way Porsche and Ferrari both are fast, it's upto your liking on what you need and what has more value to you.

Also it is easier to add a new server, then to find a new developer and work on complex codebase.

Would Adonis would be fast enough in VM with rethinkDB for calculating/displaying statistics and scrapping data from the web etc? (Compared to Express)

I ask because I love the way you explain this - I come from Laravel/Nginx - 0 experience in Node

@Extarys I believe there should be no bottlenecks

Thanks!!

@Extarys i'm using Laravel/Vue and i'm also interested in leaving PHP for Node.

Can you tell me about your experience so far?

@digitalit Well, I've never used anything else than PHP. For me the learning curve is quite rough because I like my projects big and I'm not the Hello world tutorial type of guy. But it is amazing. I prefer Koa to Express for Adonis is very nice and will be used in my next project (Once I'm done with the ones I'm working on).

The community is great but there is so many ways of doing things that you might get lost a little. For sure SO community is always helpful.

It's fast and reliable. Just need to get used to the async way of things. When you've benn stuck with PHP for so long the mentality is totally different. I'm still using PHP for a project though. I also heard sometimes people use both NodeJS and PHP on the same project to meet different needs. I need to investigate this though. It can be used by using Nginx as a proxy.

Let me know if you need anything else ;)

(Cnsider looking into RethinDB too, it's awesome I'm ditching MySQL gradually for it, very easily scallable)

I'm not affiliate with any of the open source project stated above and this reflect my pure and unbiased experience with those.

@Extarys feeling more and more determined to proceed into the Node/Adonis world.

Wont there be problems with complicated table joins with RethinDB?

Do you have any experience of running node development inside Docker container?

Thank you!

Closing, since not actionable

@digitalit

I don't use Docker - I prefer the download and install method instead of "everything is on the net and if a service close I wont be able to install anything" :P (I have a local mirror of the NPM packages I use too)

For the join query it's a getting used to, but it feels right for complicated joins. Also I like how you can manipulate all the data into sub-function and comment every line :P

I will refer you to the official rethinkDB documentations: https://rethinkdb.com/docs/table-joins/

Also to the official rethinkDB Github page for further discussion and help (since this is for Adonis and not rethinkDB) : https://github.com/rethinkdb/rethinkdb

See you there!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

themodernpk picture themodernpk  路  3Comments

dezashibi picture dezashibi  路  4Comments

milosdakic picture milosdakic  路  3Comments

begueradj picture begueradj  路  3Comments

devcaststudio picture devcaststudio  路  3Comments