Benchmarks: Node.js vs Go 1.1

Update : I updated these tests for 2014 and the latest versions of Go and Node. Enjoy!

Following the success of my last Go vs. Node post, I've received requests to repeat the tests with Go 1.1 and Node 0.10. The same rules apply here as last time; take these with a lattice of Sodium Chloride, as the benchmarks tell us information, not answers.

Without further ado, here's a simple Bubble sort. Yes, we're using a bubble sort because it is intentionally inefficient and pushes the language to make several unnecessary calculations. It would not be fair to compare the two's native sorting algorithms, as this would not be a direct comparison.

Bubble sort


var starttime = new Date().getTime();

var array = [3,4,1,3,5,1,92,2,4124,424,52,12];

for (var c = 0; c < 1000000; c++) {
    for (var i = 0; i < array.length; i++) {
        for (var y = 0; y < array.length - 1; y++) {
            if (array[y+1] < array[y]) {
                var t = array[y];
                array[y] = array[y + 1];
                array[y + 1] = t;
console.log(new Date().getTime() - starttime);


package main

import "fmt"
import "time"

func main() {

    timestart := time.Now();

    array := [...]int16{3,4,1,3,5,1,92,2,4124,424,52,12}

    for c := 0; c < 1000000; c++ {

    for i := 0; i < len(array); i++ {
        for y := 0; y < len(array) - 1; y++ {
            if array[y+1] < array[y] {
                t := array[y]
                array[y] = array[y+1]
                array[y+1] = t



    timeend := time.Now();




Node.jsGo 1.1
Avg of 5 trials 430ms 326.26ms
Best 420ms 290.272ms

Time taken to complete 1,000,000 bubble sort operations. Lower is better.

Go wins the test, but note the huge difference between the mean and the best; Go has a very large standard deviation in the data set, and did in all the cases I repeated the test. I'm really not sure why this is.

Plain HTTP


var http = require("http");

http.createServer(function(request,response) {

    response.write("You requested " + request.url);



package main

import (

func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "You requested %s", r.URL.Path)

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


Again, lower is better

It is observed that Go continues its dominance when handling raw HTTP requests. I will note, though, that upon increasing the concurrency from 100 to 1000, Go spikes erratically, with some tests as high as 10k requests per seconds, and others as low as 6k, with no clear pattern. Since I was not able to replicate these results consistently, I'm leaving this as an observation only.

Bottleneck: Redis

I wanted to experiment with some bottlenecks, because rarely would one be relying purely on the host language to handle a complete request. In most cases, a central database will be a very large and annoying bottleneck in an application.

For this reason, I wanted to see how the two stacked up when connecting to a Redis backend.


package main

import (

func errHndlr(err error) {
        if err != nil {
                fmt.Println("error:", err)

func main() {
        c, err := redis.DialTimeout("tcp", "", time.Duration(10)*time.Second)
        defer c.Close()


        c.Cmd("select", 8)

        http.HandleFunc("/", func(w http.ResponseWriter, r * http.Request) {

                s,_ := c.Cmd("get", "count").Int()

                fmt.Fprintf(w, "%n", s)

                c.Cmd("set", "count", s)
        http.ListenAndServe(":8080", nil)


var http = require("http")
var client = require("redis").createClient();;

var server = http.createServer(function(req,rep) {

        client.get("count", function(err,reply) {
                if (!reply) reply = 0;
                client.set("count", reply);

And without further ado,


Now that is interesting. Go experiences better response time, but increases at a faster rate than Node.js, crossing over at around 5.2k requests. The difference after that point is small, but perhaps not negligible.

Again, it's worth noting Go showed variance between 4k and 7k request per second, whereas Node.js scored 4.8k to 4.9k in nearly every sample. Given that, I highly recommend benchmarking the two, even with sample code like this, on your own machine with your own configuration.


I refuse to draw any conclusions, because again, benchmarks should not be the determining factor. I will, however, state that Go 1.1 continues to outpace Node.js, and even the HTTP layer seems to have been 1-upped now. However, when a bottleneck is added, the two perform with a much smaller gap, leading to more evidence that the two should be compared based on use-case and preference, not purely benchmarks.

It is also my anecdotal experience in these tests that Node seems to handle increasing loads more linearly than Go, but this is something that will almost entirely depend on the use case itself.

Any questions, suggestions, or better points are welcomed (and encouraged)

Update : I updated these tests for 2014 and the latest versions of Go and Node. Enjoy!