-2

Update: Answered question with results from the web server hosted on VPS (Vultr)

I compared it against a NodeJS/Express server to achieve a point of comparison.

What have I done wrong?

Go server:

package main

import "github.com/gin-gonic/gin"

func main() {
    gin.SetMode(gin.ReleaseMode)
    router := gin.Default()
    router.GET("/ping", func(c *gin.Context) {
        c.JSON(200, gin.H{
            "message": "pong",
        })
    })
    router.Run("0.0.0.0:9999")
}

Express Server:

const express = require('express')
const app = express()

app.get('/ping', (req, res) => res.send({ pong: 'pong' }))

app.listen(9999, () => console.log('Example app listening on port 9999!'))

Test

Tool was Vegeta

echo "GET http://localhost:9999/ping" | vegeta attack -rate=500 -duration=10s | vegeta report    

Duration: 10s
Requests: 500 per s

Results

Go/Gin's Mean Response Time: 13000ms

Node/Express's Mean Response Time: 24ms

David Alsh
  • 6,747
  • 6
  • 34
  • 60
  • 1
    Updated the question with the details – David Alsh Feb 23 '18 at 01:35
  • 1
    @DavidAlsh I ran your go code under ab -n 10000 -c 10 and got 8550 reqs/sec, max service time of 16ms. Check how you are using vegeta. – Jonah Benton Feb 23 '18 at 01:39
  • 1
    @DavidAlsh: the system configuration and test methodology are more important in benchmarks than the toy code you're presenting. A response time of `13000ms` means something is broken, so you need to start by analyzing the entire system. – JimB Feb 23 '18 at 01:42
  • @JonahB: It must be the system then. I have updated with my usage of Vegeta. I think I'll try the test on a VPS to exclude my system as a variable – David Alsh Feb 23 '18 at 01:45
  • closed the question with the results from the VPS test – David Alsh Feb 23 '18 at 05:28

1 Answers1

-1

I put the test up on a VPS and compared their results. Looks like Go is king

5s @ 1000R/s
Node:   [mean, 50, 95, 99, max]  611.524µs, 514.504µs, 768.853µs, 3.121218ms, 8.340432ms
        [success rate]           100%

Go:     [mean, 50, 95, 99, max]  485.536µs, 425.167µs, 803.236µs, 1.47899ms, 7.783679ms
        [success rate]           100%


5s @ 2500R/s
Node:   [mean, 50, 95, 99, max]  389.480416ms, 417.458353ms, 909.933675ms, 1.592021109s, 2.335314996s
        [success rate]           60.22%

Go:     [mean, 50, 95, 99, max]  223.248847ms, 217.48063ms, 376.252228ms, 436.460213ms, 636.40045ms
        [success rate]           100%


5s @ 3750R/s
Node:   [mean, 50, 95, 99, max]  321.055317ms, 132.748021ms, 1.174121791s, 1.66130059s, 2.381339843s
        [success rate]           26.45%

Go:     [mean, 50, 95, 99, max]  294.135919ms, 319.996625ms, 512.918987ms, 549.590029ms, 30.119526908s
        [success rate]           78.42%


5s @ 5000kR/s
Node:   [mean, 50, 95, 99, max]  632.77873ms, 614.378281ms, 1.108413609s, 1.505165854s, 2.156899637s
        [success rate]           26.87%

Go:     [mean, 50, 95, 99, max]  372.278943ms, 389.118423ms, 546.388561ms, 866.47292ms, 30.124971521s
        [success rate]           46%
David Alsh
  • 6,747
  • 6
  • 34
  • 60