我在 Golang+Martini 和 Play Framework 2.2.x 中编写了两个相等的项目来比较它们的性能。两者都有 1 个渲染 10K HTML 视图的操作。测试它ab -n 10000 -c 1000并通过ab输出和监视结果htop。两者都使用生产 confs 和编译视图。我想知道结果:
Play: ~17000 req/sec + constant 100% usage of all cores of my i7 = ~0.059 msec/req
Martini: ~4000 req/sec + constant 70% usage of all cores of my i7 = ~0.25 msec/req
...据我所知,马提尼酒并不臃肿,为什么它慢了 4.5 倍?有什么办法可以加速?
更新:添加了基准测试结果
Golang + 马提尼:
./wrk -c1000 -t10 -d10 http://localhost:9875/
Running 10s test @ http://localhost:9875/
10 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 241.70ms 164.61ms 1.16s 71.06%
Req/Sec 393.42 75.79 716.00 83.26%
38554 requests in 10.00s, 91.33MB read
Socket errors: connect 0, read 0, write 0, timeout 108
Requests/sec: 3854.79
Transfer/sec: 9.13MB
玩!框架 2:
./wrk -c1000 -t10 -d10 http://localhost:9000/
Running 10s test @ http://localhost:9000/
10 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 32.99ms 37.75ms 965.76ms 85.95%
Req/Sec 2.91k 657.65 7.61k 76.64%
276501 requests in 10.00s, 1.39GB read
Socket errors: connect 0, read 0, write 0, timeout 230
Requests/sec: 27645.91
Transfer/sec: 142.14MB
马提尼与 runtime.GOMAXPROCS(runtime.NumCPU())
我想在生产中使用 golang,但是在这个基准测试之后我不知道我该如何做出这样的决定......
有什么办法可以加速?
MM们
相关分类