Node performance: Hapi, Express.js, Restify

John-DanielRaygun Labs, Tech Stuff, Web Development17 Comments

Following on from our recent post about Node.JS vs io.JS performance, we received a lot of comments asking about the performance of various web frameworks. We’d only tested Express & Raw Node, so it made sense.

NOTE : We have updated this test for 2016 here.

The test

We ran a simple test that closely matches our use case for our API. That means receiving a request and giving a response (in our test, this is just ‘hello world’). For our purposes, this makes sense.

If you’re reading this post with a mind to what framework to choose for building a website, you’re likely doing yourself a disservice. These frameworks offers a lot more to folks building rich web applications and what those features are is likely more important than raw throughput.

We’ve tested Hapi, ExpressJS, Restify and naked Node with no middleware.

We also identified that Restify keeps connections alive which removes the overhead of creating a connection each time when getting called from the same client. To be fair, we have also tested Restify with the configuration flag of closing the connection. You’ll see a substantial decrease in throughput in that scenario for obvious reasons.

The results

Hapi vs Express vs Restify vs Node performance

The winner

This is a tough one with no super clear winner. Here’s why:

1. Restify is a clear winner here. Especially if you’re building a service that receives lots of requests from the same clients and want to move quickly. You of course get a lot more bang for buck than naked Node since you have features like DTrace support baked in.
2. If the cost of your servers is becoming a problem due to volume, rewriting to raw Node.JS will help you handle more requests, but be wary of what you lose (e.g. DTrace support, logging features, etc).
3. If you’re building a richer web app, you’d want to review the offerings based on feature set. Restify is not designed for heavy browser apps, while Hapi and Express are.
4. If you’re building a web app that needs thousands of requests per second, you likely have a high quality problem and should deep dive yourself 🙂

I hope that helps with answering the questions from the previous post!

Next level software intelligence across your entire stack. Get deeper analysis into how your applications are really performing. Learn more.

17 Comments on “Node performance: Hapi, Express.js, Restify”

  1. Pingback: 1p – Node performance – hapi, express and restify | OnAdvertise.com

  2. Alex Gibson

    Nice writeup, If you still have your test scripts still setup, you should output some flame graphs, it would be interesting to see were the hot-points are in each framework.

    Also, the dtrace support point about Restify is slightly inaccurate, you have dtrace by default in node, just no probes into external services (I think that’s what you were referring to), but that’s just a module away for any node app via dtrace-provider.

    Feels like a clustering article from Raygun is in order now :p

    Keep up the node tech blogging 😀
    a

  3. Michael Ryan

    Just curious what koa would look like in comparison… though with koa you’d still need to work with a router for API… but I find the abstraction for middleware/auth/logging etc is far nicer with koa.

  4. Pingback: Remote working, ASP.NET 5, TypeScript, and DocumentDB | Under the Mountain Software

  5. Pingback: Performance Showdown: Node.js vs. io.js v2.0.0

  6. Pingback: NodeJS 4.0.0 is 8% faster – we tested it! | Raygun

  7. Pingback: NodeJS 4.0.0 is 8% faster - we tested it! - The Raygun Blog

  8. Pingback: Node performance 2016: Hapi, Express.js, Restify and Koa - The Raygun Blog

  9. Pingback: Building RESTful API using Node.js: Use Hapi or Express? | Cabot Solutions

  10. Pingback: Node.js performance 2017: v7.9.0 vs. Hapi, Express.js, Restify and Koa and more

Leave a Reply

Your email address will not be published. Required fields are marked *