The JS runtimes
Published in

The JS runtimes

Deno v/s Go: Hello world performance comparison — Part 2 with fasthttp

In the previous article, I’ve compared Deno’s native HTTP server (Deno.serve) with Go’s net/http server. Go turned out slower than Deno. As promised in the previous article, I’m now comparing Deno’s native HTTP server with Go’s server based on the popular fasthttp framework. Let’s find out if fasthttp makes Go faster than Deno.

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. This article compares Deno’s native HTTP server (Deno.serve) with Go’s server based on the fasthttp framework. The test is executed for 10, 50, 100, and 300 concurrent connections.

The software versions are:

  • Deno v1.30.0
  • Go v1.19.5

The code is:

Deno

Deno.serve((_) => new Response("Hello world!"), {
port: 3000,
});

Go

package main

import (
"fmt"
"github.com/valyala/fasthttp"
)

func main() {
fasthttp.ListenAndServe(":3000", helloWorld)
}

func helloWorld(ctx *fasthttp.RequestCtx) {
fmt.Fprintf(ctx, "Hello world!")
ctx.SetContentType("text/plain; charset=utf8")
}

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)

Yes, armed with fasthttp framework, Go performs better than Deno. The fasthttp framework justifies its name. For 300 concurrent connections, Go offers 183K RPS while Deno offers 166K RPS. Deno uses less CPU, while Go’s memory usage is minimal when compared to Deno.

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