瞎扯淡 一大早无聊。来发发没有参考价值的 benchmark

zfjoy520 · 2014年04月24日 · 最后由 zfjoy520 回复于 2014年04月24日 · 5525 次阅读

环境和测试结果与下面这个 github 上的兄弟基本一致,我的 mac mini 跑出来还要高一点点

https://github.com/luislavena/bench-micro

抄一个过来。免得有人懒不想点过去

Requests/sec

Framework            Requests/sec  % from best
----------------------------------------------
rack                      8808.74       100.0%
mustermann                7673.94       87.12%
cuba                      7550.91       85.72%
hobbit                    7447.90       84.55%
lotus-router              7346.17        83.4%
rack-response             6847.69       77.74%
brooklyn                  6513.61       73.94%
rambutan                  5991.08       68.01%
nancy                     5762.34       65.42%
nyny                      4111.48       46.68%
sinatra                   2879.52       32.69%
scorched                  1654.10       18.78%
ramaze                    1341.83       15.23%

当然,任何以 hello world 来跑的 benchmark 都是瞎扯蛋。

但 lua 的 gin (http://gin.io/) + openresty(http://openresty.org/) 即能跑 35K,还是让人觉得比较爽。

因为 gin 是纯 json 的 framework,硬性规定 header 里头 Accept 的格式,有兴趣的可以关注一下: http://gin.io/docs/api_versioning.html

所以在用 wrk 跑的时候需要指定 header,配置文件如下:

#config.lua
wrk.headers["Accept"] = "application/vnd.xxxx.v100+json"

测试一: 返回定值json:{'hi': 'gin'}

wrk -t12 -c400 -d10s  http://127.0.0.1:7200 --script="config.lua"
Running 10s test @ http://127.0.0.1:7200
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    11.64ms   12.63ms 149.18ms   91.22%
    Req/Sec     3.09k     0.95k   12.92k    84.73%
  355662 requests in 10.00s, 84.10MB read
  Socket errors: connect 0, read 201, write 0, timeout 0
  Non-2xx or 3xx responses: 355662
Requests/sec:  35561.76
Transfer/sec:      8.41MB

测试二: 一次ssdb get之后再返回定值json:{'hi': 'gin'}

配合上 redis 或者是 ssdb(http://www.ideawu.com/ssdb/zh_cn/)。 带一个简单的 get 查询。效率低了不少。但感觉应该还是会比 rails,rack 这一类快上不少。

wrk -t12 -c400 -d10s  http://127.0.0.1:7200 --script="config.lua"
Running 10s test @ http://127.0.0.1:7200
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    50.77ms   46.63ms 119.63ms   48.43%
    Req/Sec     1.70k     0.94k    7.00k    79.68%
  163995 requests in 10.00s, 32.05MB read
  Socket errors: connect 0, read 403, write 0, timeout 0
Requests/sec:  16399.01
Transfer/sec:      3.21MB

16K,是带了一个 ssdb get 的,返回值还是 json 的一个 benchmark 哟。

说到最后。其实我是来打广告的

ssdb: http://www.ideawu.com/ssdb/zh_cn/

gin: http://gin.io/ -- 一个基于 lua 的 JSON-API framework,做 web service 不错

openresty:http://openresty.org/ -- a fast web app server by extending nginx

有兴趣的童鞋可以关注一下。

sinatra ...

^_^,之前还有 rails 的 benchmark,后来估计是被 github 上那位仁兄给抛弃了。

看了简介,openresty 是 non-blocking IO 的,LZ 可以测下 eventmachine 与之对比

gin 运行在 nginx 上面?那 mruby 其实也能做到啊,不知有没高手去试下....

#4 楼 @jjym gin 运行在 openresty 这个改过的 nginx 上。

gin db 部分用 dbi 在 openresty 应该是不行的,会阻塞

这个其实讨论过,单测试 hello,world 实际意义不大,因为最后一棒是数据库,大部分应用都因为最后一棒太慢,相差不多,换 nosql 另外说了。

怎么没有 ring 的

#8 楼 @mjf429 估计 github 上那兄弟对 clojure 不熟

需要 登录 后方可回复, 如果你还没有账号请 注册新账号