Benchmarking Web Framework Response Times (Part 2) — Enter Node.js
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?
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.
ab -n 100 -c 10 http://127.0.0.1:3333/books/Concurrency 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.