Benchmarking Web Framework Response Times (Part 2) — Enter Node.js

James Judd
Nov 4, 2018 · 2 min read

In August I wrote a blog post which benchmarks the response times of Laravel, ASP.NET Core MVC and Django. In short, I wrote a small API endpoint in each framework (which lists books stored in a MySQL database), Dockerised it, and then ran ab — the Apache Benchmarking tool, to see which framework has the quickest response time.

No surprise that the compiled language C# had the quickest response time, but how will a Node.js application fair against its response times?

AdonisJs is the Node.js MVC framework I have chosen for this comparison, mainly because we use it in production at Netsells, the company I work for. The previous frameworks tested are predominately synchronous, however Node.js is an asynchronous Javascript runtime. Given that this benchmarking test is to see how fast the server can respond to multiple concurrent requests, the Node.js server should be able to leverage the benefits of being asynchronous, and perform useful work for other clients while blocked waiting on the database, ultimately reducing the mean response time.

The Application

At Netsells we predominately use Laravel for backend applications. AdonisJs is remarkably similar, including the way it handles routing, configuration, database models and creating files via the CLI.

You can find the application code on GitHub. Making this application was very straight forward, AdonisJs provides a few different boilerplate repositories, I use the one specifically for building an API. Also Dockerising this application was very straight forward, and the Dockerfile in the application serves as a good basic example for those looking to learn how to Dockerise a Node.js application.

The Results

ab -n 100 -c 10 Level:      10
Time taken for tests: 0.283 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 29800 bytes
HTML transferred: 15500 bytes
Requests per second: 352.88 [#/sec] (mean)
Time per request: 28.338 [ms] (mean)
Time per request: 2.834 [ms] (mean, across all concurrent requests)
Transfer rate: 102.69 [Kbytes/sec] received

AdonisJs finished in second place, with a mean response time of 28.34 ms.

The asynchronous foundations of Node.js clearly allow the runtime to be used to produce fast web applications — ahead of the two other interpreted language frameworks, Django and Laravel — but an order of magnitude slower than the compiled language option — ASP.NET.

James Judd

Written by

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade