Deno vs Go

| Reading Time : 3 minutes | #backenddevelopment #Go


This is unusual of me to think putting two technologies head on head but I got curious recently seeing the comparision chart from https://bun.sh/ comparing it with node and deno and wanted to try myself with deno and go which i am using at the moment but not to evaluate and choose the winner for my work but rather to satisfy my curiousity. Posting these results here so incase if you ever wanted to do one here is the summary from my experiment

comparision_chart

GOAL: I just wanted to get only one metric out “which ones serves highest number of requests per second”

1. Golang:

This code is straight lifted from example at https://gobyexample.com/http-servers . Its best explained whats this code does in this website but essentially we register our handler “/” using http.HandleFunc convenience function. It sets up the default router in the net/http package and takes a function as an argument. We then call the ListenAndServe function with port 8081

package main

import (
	"fmt"
	"net/http"
)

func hello(w http.ResponseWriter, req *http.Request) {
	fmt.Fprintf(w, "hello\n")
}

func main() {
	http.HandleFunc("/", hello)
	http.ListenAndServe(":8082", nil)
}

2. Deno

This code again is nothing fancy a simple example picked up from deno’s official website https://deno.land/manual@v1.26.0/examples/http_server essentially here too all this is doing is starting http server on 8081 port on “/” returning 200 ok.

import { serve } from "https://deno.land/std@0.158.0/http/server.ts";

const port = 8081;

const handler = (request: Request): Response => {
    return new Response(null, { status: 200 });
};

console.log(`HTTP webserver running. Access it at: http://localhost:8081/`);
await serve(handler, { port });

To test these api’s i am using a tool called hey built by Jaana Dogan. its a simple tool to stress test a endpoint and produce result detailed information in many aspects. It does gives number of requests per second which is our GOAL of this experiment.

creteria’s considered :

  1. Number of requests to run: 100/10000
  2. Number of workers to run concurrently: 50/500
  3. Duration: 30 seconds

Here in the graph its clear go program in these two scenarios performed ateast 4-5 times faster than Deno in serving number of requests per second. While this example is not a real world use case where it would be much more cpu and IO intensive requirements hence these results are indicators rather than a true like to like comparisions. Last but not the least here are machine specs under which tests were run

credits:

  1. Deno image: https://github.com/heymicodes
  2. Go image: https://github.com/egonelbre/gophers
  3. Go code snippet: https://gobyexample.com/http-servers
  4. Deno code snippet: https://deno.land/manual@v1.26.0/examples/http_server

Last but not least here are the machine specifications under which I ran this test

machine_specs


Articles from blogs I follow around the net

powerctl: A small case study in Hare for systems programming

powerctl is a little weekend project I put together to provide a simple tool for managing power states on Linux. I had previously put my laptop into suspend with a basic “echo mem | doas tee /sys/power/state”, but this leaves a lot to be desired. I have to u…

via Drew DeVault's blog August 28, 2022

United States v. Microsoft Corp exhibits

Links to exhibits from the Microsoft anti-trust case, with a bit of info on each link. Projection of PC marketshare Share of new browser users Share of the browser market, grouped by major ISP, 3 month moving average Share of the browser market, grouped by ma…

via danluu.com August 24, 2022

Status update, August 2022

Hi all! This month I’ve been pondering offline-first apps. The online aspect of modern apps is an important feature for many use-cases: it enables collaboration between multiple people and seamless transition between devices (e.g. I often switch between my pe…

via emersion August 14, 2022

Generated by openring

© Copyright 2021-2022. Rakesh Mothukuri