Deno vs Go: Native hello world performance

Mayank Choubey
Tech Tonic
Published in
3 min readNov 6, 2023

--

In this concise piece, we delve into a head-to-head performance comparison of native servers offered by Deno and Go, focusing on the classic ‘Hello World’ benchmark. This topic has piqued the interest of our readers, prompting multiple requests for an in-depth exploration, especially after Deno has an improved native server since the last benchmarking.

Setup

We conducted all tests on a MacBook Pro M2 with 16GB of RAM, using specific software versions:

  • Deno v1.38.0
  • Go v1.21.3

To generate HTTP load, we utilized the Bombardier test tool. Below is the application code we used:

Deno

Deno.serve({
port: 3000,
}, (req) => {
try {
const pathName = new URL(req.url).pathname;
if (pathName !== "/") {
return new Response(null, { status: 404 });
}
return new Response("Hello world!");
} catch (e) {
return new Response(null, { status: 500 });
}
});

Go

package main

import (
"io"
"net/http"
)

func main() {
http.HandleFunc("/", helloWorld)
http.ListenAndServe(":3000", nil)
}

func helloWorld(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello world!")
}

You might be curious why Deno code has more lines than Go. This is because Deno’s built-in server lacks routing capabilities.

Results

All tests are executed for 10 million requests using 50, 100, and 300 concurrent connections. The results in chart and tabular form are as follows:

Conclusion

We didn’t anticipate Deno outperforming Go. Surprisingly, in a basic hello world scenario, Deno’s built-in server is only about 30% slower than Go’s. Go uses a lot of CPU, whereas Deno uses more memory.

Thanks for reading!

--

--