关注各种黑科技
B站UP主,编程教学,游戏玩家,挂B,金牛座

网站性能测试工具 wrk

wrk 是一款lua性能测试工具, 这里用它来测试一些常见的web框架吞吐性能。 测试结果仅供参考,正式环境中优化web性能,需要考虑和改进的问题都需要大量经验累积。   安装 $ brew install wrk   测试命令 $ wrk -t16 -c100 -d30s http://127.0.0.1:<port>/ 16线程  100并发 持续30秒   测试环境 系统macos i5 8G      

go语言

gin   lu fasthttp
package main
import (
    "github.com/valyala/fasthttp"
    "github.com/vincentLiuxiang/lu"
)
func main() {
    app := lu.New()
    app.Use("/", func(ctx *fasthttp.RequestCtx, next func(error)) {
        ctx.SetBody([]byte("my name is go"))
    })
    server := &fasthttp.Server{
        Handler:     app.Handler,
        Concurrency: 1024 * 1024,
    }
    server.ListenAndServe(":8080")
}
 
Running 30s test @ http://127.0.0.1:8080/
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    71.90ms  234.88ms   1.99s    91.45%
    Req/Sec    24.11k    25.41k   60.15k    66.84%
  1680600 requests in 30.04s, 232.40MB read
  Socket errors: connect 0, read 0, write 0, timeout 599
Requests/sec:  55945.86
Transfer/sec:      7.74MB
     

python语言

python3.6   django 内置server django-admin startproject djangotest gunicorn djangotest.wsgi:application --workers=2 --worker-class=meinheld.gmeinheld.MeinheldWorker wrk -t16 -c100 -d30s http://127.0.0.1:8000/  
Running 30s test @ http://127.0.0.1:8000/
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    24.83ms   53.09ms   1.69s    99.49%
    Req/Sec    84.43     43.47   232.00     63.13%
  16524 requests in 30.04s, 30.19MB read
  Socket errors: connect 0, read 3, write 0, timeout 9
Requests/sec:    550.03
Transfer/sec:      1.01MB
  django gunicorn meinheld sanic
from sanic import Sanic
from sanic.response import json
app = Sanic()
@app.route("/")
async def test(request):
    return json({"hello": "world"})
if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)
 
Running 30s test @ http://127.0.0.1:8080/
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     4.73ms    1.47ms  36.93ms   95.54%
    Req/Sec     1.30k   174.50     1.71k    93.04%
  619871 requests in 30.02s, 80.40MB read
Requests/sec:  20650.08
Transfer/sec:      2.68MB
 

nodejs语言

koa2 node  --harmony  app.js
const Koa = require('koa');
const app = new Koa();
app.use(async (ctx, next) => {
    await next();
    ctx.response.type = 'text/html';
    ctx.response.body = 'hello world';
});
app.listen(3000);
 
Running 30s test @ http://127.0.0.1:3000/
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    12.01ms    3.69ms  94.97ms   93.89%
    Req/Sec   508.46     78.39   787.00     77.17%
  243463 requests in 30.10s, 35.06MB read
Requests/sec:   8089.47
Transfer/sec:      1.16MB
   

dotnetcore

run wo debug
app.Run(async (context) =>
{
    await context.Response.WriteAsync("Hello World!");
});
 
Running 30s test @ http://127.0.0.1:5000/
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     9.34ms   12.80ms 250.32ms   93.42%
    Req/Sec     0.85k   227.41     1.89k    71.66%
  406290 requests in 30.09s, 47.66MB read
Requests/sec:  13504.27
Transfer/sec:      1.58MB
   

nginx

Running 30s test @ http://127.0.0.1:80/
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    95.05ms  128.43ms 620.59ms   79.50%
    Req/Sec     1.74k     1.22k    6.06k    74.55%
  712435 requests in 30.06s, 577.48MB read
Requests/sec:  23698.55
Transfer/sec:     19.21MB
    成绩       可能回遇到的错误 (linux系统中) unable to create thread 15: Too many open files ulimit -n 2048
转载请注明出处
分享到: 更多 (0)

评论 0