Deno’s new server vs Node.js: Performance comparison for Hello world

Mayank C
Tech Tonic

--

From v1.25, Deno has introduced a totally new HTTP server called flash. The flash server is still under the unstable umbrella. The flash server is limited to HTTP/1.1 only. There is no HTTP/2 support yet. Deno authors claim that the server is two times faster than Node.js. In this comparison, we’ll find it out.

A similar comparison with the ‘stable’ HTTP server is here.

Test setup

Environment

The performance comparison is executed on the following environment:

  • System: MacBook M1 with 16G of memory
  • Local: The SUT and tester are on the same system
  • Deno version: 1.25.0
  • Node version: 18.8.0

Code

The following is the code for Hello world in both the runtimes. In both cases, only native APIs are used.

Node.js

const http = require('http');http.createServer((_, resp) => {
resp.writeHead(200, {
'Content-Type': 'application/json',
});
resp.end(
JSON.stringify({ respData: 'Hello world' }),
);
}).listen(3000);

Deno

Deno.serve((_) => Response.json({ respData: 'Hello world' }), { port: 3000 });

Even natively, the Deno hello world server can be written in a single line of code

Settings

The performance test is executed in following configurations:

  • 10 concurrent connections to run a total of 10K requests
  • 25 concurrent connections to run a total of 10K requests
  • 50 concurrent connections to run a total of 10K requests

Measurements

The following measurements are recorded for each test configuration:

  • Time taken
  • Requests per second
  • Minimum
  • 1st Quartile
  • Median
  • Mean
  • 3rd Quartile
  • Maximum
  • CPU usage
  • Memory usage

Results

A total of 10K requests are executed for each test configuration.

For ease of comparison, all the results are summarized graphically. Here are the 16 graphs covering each of the above measurement:

The time taken to run 10K requests (less is better)
The number of requests handled per second (more is better)
The minimum response time across 10K requests (less is better)
The 10th percentile response time for 10K requests (less is better)
The 1st quartile response time for 10K requests (less is better)
The mean / average response time for 10K requests (less is better)
The median response time for 10K requests (less is better)
The 3rd quartile response time for 10K requests (less is better)
The 90th percentile response time for 10K requests (less is better)
The maximum response time across 10K requests (less is better)
The CPU usage distribution for 10 concurrent connections (low is better)
The CPU usage distribution for 25 concurrent connections (low is better)
The CPU usage distribution for 50 concurrent connections (low is better)
The memory usage distribution for 10 concurrent connections (low is better)
The memory usage distribution for 25 concurrent connections (low is better)
The memory usage distribution for 50 concurrent connections (low is better)

Conclusion

So, what’s the conclusion? Well, Deno’s new flash server is surely a significant improvement over the older server. The performance has improved when compared to Node.js’s native HTTP server. But the claim that it is two times faster than Node.js doesn’t seem entirely true.

--

--