Deno’s native (hyper) vs Node’s native HTTP servers
Introduction
Before v1.9.0, Deno’s HTTP server implementation was in TypeScript. Up to TCP connection handling, the implementation was in Rust, then the entire HTTP handling was done in TypeScript. In other words, the HTTP server was scripted (or interpreted). Even though the HTTP server was scripted, the performance was pretty decent.
From v1.9.0 (though still under unstable umbrella), Deno has moved HTTP server implementation to Rust, utilizing a high performance HTTP server library called Hyper. Hyper is an asynchronous, low-level, fast, and performant HTTP server. It is also backed by extensive production use. Off recently, there has been a lot of interest in the new HTTP server. Hyper has a lot of hype!
In this article, we’ll compare the performance of Deno’s native HTTP server with Node’s native HTTP server. We’ll find out if Hyper lives to its hype.
Code
For the comparison, we’ll use a small HTTP server that echoes the name back to the client. It reads and returns JSON. Here is the implementation of the HTTP server in Deno and Node.js:
Both the servers parses incoming JSON body, takes the name out and returns it back in the output JSON response.
Pretty simple! Nothing complicated.
Comparison
The test environment is a MacBook Pro with core i5 and 8G of RAM.
We’ve tested from single to 50 concurrent connections. We’ll see an overall comparison along with a detailed quantile analysis with graphs.
Concurrency=1
For a single connection, Deno performs slightly better than Node.js
Concurrency=10
For 10 concurrent connections, Deno still performs slightly better than Node.js.
Concurrency=25
For 25 concurrent connections, Deno performs slightly worse than Node.js
Concurrency=50
For 50 concurrent connections, Deno performs slightly worse than Node.js
Summary
Well, that was a lot of data, tables, graphs, etc. Let’s try to summarize it.
One of the key metrics is requests/second for each concurrency level. Requests per second covers a lot of ground because it gets worse when the system gets slower. It is the one of the best indicator to assess the responsiveness.
Here is a summarized column chart of requests per second / concurrency.
To summarize, Deno’s hyper based native HTTP server performs at par with Node.js’s native HTTP server. There is no major difference in the performance.
This story is a part of the exclusive medium publication on Deno: Deno World.