更新:回答了来自VPS(Vultr)上托管的Web服务器的结果的问题
我将它与NodeJS / Express服务器进行了比较,以达到比较的目的。
我做错了什么?
去服务器:
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
工具是Vegeta
echo "GET http://localhost:9999/ping" | vegeta attack -rate=500 -duration=10s | vegeta report
Duration: 10s
Requests: 500 per s
Results
Go / Gin的平均响应时间:13000ms
节点/快车的平均响应时间:24ms
答案 0 :(得分:-1)
我将测试放在VPS上并比较他们的结果。 看起来像Go是王
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%