doqpm82240 2014-03-14 23:39
浏览 82
已采纳

为什么Go的Martini的性能不如Play Framework 2.2.x

I wrote two equal projects in Golang+Martini and Play Framework 2.2.x to compare it's performance. Both have 1 action that render 10K HTML View. Tested it with ab -n 10000 -c 1000 and monitored results via ab output and htop. Both uses production confs and compiled views. I wonder about results:

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 I understand martini is not bloated, so why it 4.5 times slower? Any way to speedup?

Update: Added benchmark results

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.13MB

Play!Framework 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

Martini running with runtime.GOMAXPROCS(runtime.NumCPU())

I want to use golang in production, but after this benchmark I don't know how can I make such decision...

Any way to speedup?

  • 写回答

3条回答 默认 最新

  • dtbl1231 2014-06-21 15:37
    关注

    @Kr0e, right! I figured out that heavy use of reflection in DI of martini makes it perform slowly. I moved to gorilla mux and wrote some martini-style helpers and got a wanted performance.

    @Cory LaNou: I can't accept yours comment) Now I agree with you, no framework in prod is good idea. Thanks

    @user3353963: See my question: Both uses production confs and compiled views

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛