The JS runtimes
Published in

The JS runtimes

Deno v/s Go: Hello world performance comparison

Continuing my quest of performance comparisons, this article is about Deno and Go. Who do you think is faster for a simple hello world case? I guess the answer would be Go because it’s compiled into byte code while Deno is interpreted. If you’re interested in finding out the correct answer, read on. You might be surprised!

Setup

The test is executed on MacBook Pro M1 with 16G of RAM. The test is executed using the well-known HTTP tester: Bombardier. It’s interesting to know that Bombardier itself is written in Go using fasthttp. However, this article compares Deno’s native HTTP server (Deno.serve) with Go’s native server (net/http). There will another follow-up article which will compare Deno.serve with fasthttp. The test is executed for 10, 50, 100, and 300 concurrent connections.

The code is:

Deno

The Deno code has a minimal router that makes it equivalent to the functionality provided by Go’s native server.

Go

Just by looking, Go’s code looks much cleaner compared to Deno’s code.

A total of 10M (10 million) requests are executed for each concurrency level.

The following measurements are taken:

  • Time taken
  • Requests per second
  • Latencies: Mean, median, q25, q75, q90, maximum (in microseconds)
  • System usage: Average CPU and memory usage

Results

Here are the charts representing results for each type of measurement (Note that all latencies are in microseconds):

Well, I was surprised to see that Deno’s new native flash server (available through Deno.serve API) turns out to be pretty fast when compared to Go’s built-in net/http server. For high concurrency (300), Deno offers ~160K RPS, while Go offers ~110K RPS. Resource-wise, Deno uses less CPU, while Go uses very low memory (~30M vs 80M of Deno).

Overall, Deno’s native server beats Go’s built-in native server.

As promised, in a follow-up article, I’ll compare Deno’s native server with Go’s fasthttp. I’m expecting results to be different in the follow-up article.

UPDATE: As promised, the comparison with Go’s fasthttp is now available here.

More articles on similar topics can be seen in the magazine: The JS runtimes.

--

--

Articles on the popular JS runtimes, Node.js, Deno, and Bun

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store