Mayank Choubey

Jun 8, 2020

5 min read

Deno vs Node.js: Performance comparison: Hello world

This article is updated by a new article published here.

Deno is a simple, modern, and secure runtime for JavaScript and TypeScript that uses Google’s V8 JS engine. Deno is built in Rust. Deno is secure, sandboxed, runs typescript out of the box, and ships as a single executable file. In addition to running a typescript application, Deno also includes a tester, formatter, linter, inspector, etc. Deno is more than a simple way to run Typescript applications. Deno is a complete toolchain.

The first major release of Deno was in mid-May 2020, which was Deno 1.0 GA. Deno 1.0 quickly got followed by quick releases in the last six months. At the time of writing this article, the latest Deno release was 1.5.2. Deno follows a weekly release schedule for minor releases while having a major release every couple of months.

Node.js has been around for more than 11 years. It has enjoyed wide acceptance with many of the major companies using it for their production-grade systems. These are big names like Paypal, Netflix, NASA, LinkedIn, etc. Node.js is still very active and there is a major release every few months. At the time of writing this article, the latest Node.js release was 15.1.0.

Deno is in direct competition with Node.js. Well, there isn’t any competition for existing apps that are running in Node.js. It is very unlikely that Node.js apps would get converted to Deno. The competition is for new apps. Earlier it was Node.js only. Now there are two options. The biggest question is:

  • Is Deno ready for production apps?
  • Is it a reliable runtime that can run for a long time?
  • Is it able to perform as well as or even better than Node.js?

If Deno fails on the above, it’d never become a major Runtime like Node.js. It’d never compete with Node.js.

This is a series of articles that compare the performance of Deno and Node.js by running various commonly used scenarios. The reliability of Deno is another aspect that will be addressed in another series.

This is part 1 of the performance comparison series. The other parts of the series are:

  • Part 2 (Hello world: express vs oak)
  • Part 3 (Echo name over HTTPS)
  • Part 4 (Generate one hundred v1 UUIDs)

There are many HTTP load generators, a lot of them are free. Most of the available performance testers are very sophisticated and require an elaborate setup before anything useful can be done. They are very useful for comprehensive testing. But they are way too complex for simple performance testing. Also, most of them require an additional installation.

For this performance testing, a very simple performance tester has been used that runs in Deno. No extra installation required. The performance tester takes all the inputs from the command line and runs the test. It allocates workers that continuously hit the server for the specified number of requests.

This is the first performance comparison, so the choice of server is obviously a hello world web server. No third party frameworks are used as they would dilute the real purpose of this testing effort. The most basic hello world programs are written in both languages.

Deno code is here. Node.js code is here.

Environment: The performance test is executed on MacBook Pro with 8G memory and Quad-core i5 processor. The benchmarker and SUT, both runs on the same machine. There is no network delay.

Versions: Here are the Deno and Node.js versions used for performance comparison.

The performance test is executed for different values of concurrent connections with the same value of repeat. Here are three scenarios:

  • 1 concurrent connection and 1000 repetitions
  • 10 concurrent connections and 1000 repetitions
  • 25 concurrent connections and 1000 repetitions

The following readings were taken: Total time taken, mean, median, min, and max.

TEST RESULTS

Concurrency=1

Here is the overview of the results:

And, here is the detailed distribution (10% quantiles) of the readings:

Here are the graphs:

Concurrency=10

Here is the overview of the results:

And, here is the detailed distribution (10% quantiles) of the readings:

Here are the graphs:

Concurrency=25

Here is the overview of the results:

And, here is the detailed distribution (10% quantiles) of the readings:

Here are the graphs:

Analysis

At high load, Deno is consistently faster for a simple hello world program. Though, the difference isn’t significant.

This story is a part of the exclusive medium publication on Deno: Deno World.