我用Golang+Martini和Play Framework2.2.x编写了两个相同的项目来比较它的性能。两者都有一个动作,呈现10K HTML视图。用ab -n 10000 -c 1000对其进行测试,并通过ab输出和htop监控结果。这两种方法都使用生产混淆和编译视图。我想知道结果:
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...as我知道马提尼没有膨胀,那么为什么它慢4.5倍呢?有办法加速吗?
更新:添加基准测试结果
Golang + Martini:
./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.13MBPlay!框架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())运行马提尼
我想在生产中使用高丽,但是在这个基准之后,我不知道我怎么能做出这样的决定……
有办法加速吗?
发布于 2014-06-21 15:37:06
@Kr0e,对!我发现在马提尼的DI中大量使用反射使它表现得很慢。我搬到大猩猩穆克斯,写了一些马提尼风格的助手,并得到了通缉的表演。
@Cory LaNou:我不能接受你的评论)现在我同意你的观点,没有一个prod框架是好主意。谢谢
@user3353963:参见我的问题:两者都使用生产混淆和编译视图
发布于 2014-04-03 02:05:08
我制作了一个简单的马提尼应用程序,它呈现了1个html文件,而且速度相当快:
✗ wrk -t10 -c1000 -d10s http://localhost:3000/
Running 10s test @ http://localhost:3000/
10 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 31.94ms 38.80ms 109.56ms 83.25%
Req/Sec 3.97k 3.63k 11.03k 49.28%
235155 requests in 10.01s, 31.17MB read
Socket errors: connect 774, read 0, write 0, timeout 3496
Requests/sec: 23497.82
Transfer/sec: 3.11MBMacbook i7。这是应用程序https://gist.github.com/zishe/9947025 --如果你显示你的代码,也许你没有禁用日志或者遗漏了什么。
但是timeout 3496看起来很糟糕。
发布于 2014-05-19 04:57:13
添加以下代码:
func init(){
martini.Env = martini.Prod
}抱歉,你的代码已经完成了。
https://stackoverflow.com/questions/22417661
复制相似问题