Go says Hello 3x times more than Node

Just had to take wrk for a ride. Wrk installed cleanly on the laptop, just was minssing “openssl/ssl.h”. And …

$ sudo apt-get install libssl-dev

did the fix. Now it is off to test it out.

Have been hearing quite a bit about Go and its capabilities as a web framework, driven by the need to explore. Wanted to check how it performed. And needed to pit against something. Node was an obvious choice. Pit a hello-server.go against a hello-server.js. The hello-server.go looks like this.

package main

import (
  "fmt"
  "net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
  fmt.Fprintf(w, "Hello world!")
}

func main() {
  http.HandleFunc("/", handler)
  http.ListenAndServe(":8080", nil)
}

Ran go’s hello-server like this.

$ go run hello-server.go

And ran the wrk like this

$ ./wrk -t12 -c400 -d30s http://127.0.0.1:8080/
Running 30s test @ http://127.0.0.1:8080/
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     7.86ms    2.13ms  27.08ms   74.12%
    Req/Sec     4.36k   621.93     9.17k    67.09%
  1531244 requests in 29.99s, 188.38MB read
Requests/sec:  51052.62
Transfer/sec:      6.28MB

-t denotes the number of threads, -c denotes the number of open connections, -d denotes the number of seconds to run the benchmark for. This shows that hello-server.go satified 51052 requests per second.

Now off to the node, hello-server.js.

var http = require('http');
var server = http.createServer(function (request, response) {
   response.writeHead(200, {"Content-Type": "text/plain"});
   response.end("Hello World\n");
});

server.listen(8000);

console.log("Server running at http://127.0.0.1:8000/");

Ran node’s hello-server like this.

$ node hello-server.js
Server running at http://127.0.0.1:8000/

Now ran the wrk like this.

$ ./wrk -t12 -c400 -d30s http://127.0.0.1:8000/
Running 30s test @ http://127.0.0.1:8000/
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    26.25ms    4.81ms 272.52ms   94.95%
    Req/Sec     1.27k   256.02     2.38k    69.50%
  452575 requests in 30.01s, 67.33MB read
Requests/sec:  15082.66
Transfer/sec:      2.24MB

Node satified 15082 requests pre second. Though hello-servers are not a good benchmark, it is incredible to see go outperform, node by 3x.

 
0
Kudos
 
0
Kudos

Now read this

Quarantine a EKS Node with Docker Containers

While performing these step please practice caution, and have the right dashboards that will point to any issues. Step 0. Annotate the node, ip-10-102-11-188.ec2.internal, in question, to not participate in the auto-scaling. $ kubectl... Continue →