参考的这里
压测工具
wrk -t16 -c100 -d30s http://127.0.0.1:8080/rest/hello
测试代码
package main import ( "strconv" "time" "github.com/kataras/iris" "github.com/gin-gonic/gin" "net/http" "os" "github.com/labstack/echo" "github.com/labstack/echo/engine/standard" ) func makeIrisServer(timeDuration int){ api := iris.New() api.Party("rest").Get("/hello", func(c *iris.Context) { //api.Get("/rest/hello", func(c *iris.Context) { if timeDuration > 0 { time.Sleep(time.Duration(timeDuration) * time.Millisecond) } c.Write("Hello world") }) api.Listen(":8080") } func makeEchoServer(timeDuration int) { api := echo.New() api.GET("/rest/hello", func(c echo.Context) error { if timeDuration > 0 { time.Sleep(time.Duration(timeDuration) * time.Millisecond) } return c.String(http.StatusOK, "Hello, World") }) api.Run(standard.New(":8080")) } func makeGinServer(timeDuration int){ gin.SetMode(gin.ReleaseMode) //关闭日志 //router := gin.Default() router := gin.New() router.GET("/rest/hello", func(c *gin.Context) { if timeDuration > 0 { time.Sleep(time.Duration(timeDuration) * time.Millisecond) } c.String(http.StatusOK, "hello world") }) router.Run(":8080") } func main() { sleepTime, _ := strconv.Atoi(os.Args[1]) //makeIrisServer(sleepTime) //makeGinServer(sleepTime) makeEchoServer(sleepTime) }
iris
./server 0
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 1.85ms 1.59ms 104.74ms 95.48% Req/Sec 3.50k 421.36 7.09k 83.79% 1677120 requests in 30.09s, 227.12MB read Requests/sec: 55744.97 Transfer/sec: 7.55MB
./server 10
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 13.07ms 1.46ms 37.15ms 68.94% Req/Sec 459.16 39.35 580.00 70.85% 219622 requests in 30.07s, 29.74MB read Requests/sec: 7302.65 Transfer/sec: 0.99MB
./server 100
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 104.20ms 1.84ms 110.79ms 62.15% Req/Sec 57.67 5.37 116.00 97.15% 27634 requests in 30.10s, 3.74MB read Requests/sec: 917.96 Transfer/sec: 127.30KB
./server 1000
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 1.01s 1.46ms 1.01s 64.12% Req/Sec 5.27 1.58 38.00 99.57% 2784 requests in 30.09s, 386.06KB read Requests/sec: 92.52 Transfer/sec: 12.83KB
gin
./server 0
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 2.33ms 2.91ms 89.31ms 92.11% Req/Sec 3.25k 0.86k 14.52k 81.88% 1556196 requests in 30.10s, 189.97MB read Requests/sec: 51708.60 Transfer/sec: 6.31MB
./server 10
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 12.83ms 1.96ms 48.34ms 73.74% Req/Sec 468.89 44.26 590.00 57.39% 224533 requests in 30.11s, 27.41MB read Requests/sec: 7457.75 Transfer/sec: 0.91MB
./server 100
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 105.77ms 1.82ms 112.78ms 66.52% Req/Sec 57.10 5.86 116.00 96.34% 27180 requests in 30.07s, 3.32MB read Requests/sec: 903.81 Transfer/sec: 112.98KB
./server 1000
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 1.00s 2.08ms 1.01s 62.46% Req/Sec 5.21 0.41 6.00 79.31% 2784 requests in 30.09s, 348.00KB read Requests/sec: 92.52 Transfer/sec: 11.57KB
echo
./server 0
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 2.47ms 3.21ms 79.28ms 91.91% Req/Sec 3.21k 0.89k 16.60k 82.53% 1537211 requests in 30.10s, 189.11MB read Requests/sec: 51069.64 Transfer/sec: 6.28MB
./server 10
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 12.62ms 1.86ms 45.19ms 74.89% Req/Sec 476.33 41.71 590.00 58.02% 227976 requests in 30.09s, 28.05MB read Requests/sec: 7575.22 Transfer/sec: 0.93MB
./server 100
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 105.16ms 1.88ms 113.46ms 63.02% Req/Sec 57.33 5.38 103.00 96.94% 27360 requests in 30.09s, 3.37MB read Requests/sec: 909.37 Transfer/sec: 114.56KB
./server 1000
Running 30s test @ http://127.0.0.1:8080/rest/hello 16 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 1.00s 1.99ms 1.01s 62.32% Req/Sec 5.29 1.39 30.00 99.14% 2784 requests in 30.10s, 350.72KB read Requests/sec: 92.50 Transfer/sec: 11.65KB