Node performance: Hapi, Express.js, Restify
Posted Mar 5, 2015 | 2 min. (365 words)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
The winner
This is a tough one with no super clear winner. Here’s why:
-
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.
-
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).
-
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.
-
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!