[Update: since these benchmarks were run, performance of Restify has improved substantially to where its performance is on a par with the others. I have not got around to updating the charts in this article to reflect that].
In the cloud today, performance is more important than ever because it can be so easily correlated with cost. If my app can handle 100 requests per second using a single CPU in the cloud, then that means that it will cost me 10 cpus if I need to handle 1,000 requests per second. In the cloud, 10 CPUs cost 10x as much as 1 cpu.
PerfectAPI is my open-sourced Node.js-based service API module. It is designed to be used as an API server that’s easy to write and easy to use. It is mildly RPC-biased, although it includes many REST principles and exposes similar HTTP endpoints. I wanted to run some benchmarks in order to validate its performance.
I chose to compare to Express.js because PerfectAPI uses Express.js and so it could not possibly perform any better. (So its a good baseline). I chose to also compare to Restify.js because it is a similar product.
First off, Express.js is a performance god. Although I wasn’t able to replicate these results, my tests regularly averaged a very respectable 1,600-1,700 requests per second. My sample app for PerfectAPI did around 1,000 requests per second. Restify.js, I’m sorry to say, was much slower – around 250 requests per second. Memory usage for all 3 was very low, as expected with Node. The text results are all here, with the associated code here.
Here is a chart showing all three (note, this chart is out of date since Restify performance issues were resolved):
As you can see, Restify.js is not in the same league. I’m sure it is nothing structural, it probably just needs some performance tuning. Excluding Restify, the same chart looks like this:
You can see that as expected, Express.js is faster. PerfectAPI is no slouch though, and scales similarly. I don’t think the upturns at the end mean anything significant – to prove that to myself, I doubled the run to 16,000 and you can see that the performance is consistent over the length (although it has another upturn at the end).
Well that’s all I have really. Please comment below if you have questions or observations.