瞎扯淡 小应用,thin 比 puma 更靠谱

cxh116 · 2013年07月16日 · 最后由 cxh116 回复于 2013年07月17日 · 5127 次阅读

无论是性能,还是部署启动方式

这是网上搜索到的一个测试比较结果 https://gist.github.com/torbjon/4286777

这是自己的 sinatra + datamapper 小应用测试结果. 测试命令ab -c 10 -n 1000 http://127.0.0.1:9292/c/11

thin 结果

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        thin
Server Hostname:        127.0.0.1
Server Port:            9292

Document Path:          /c/11
Document Length:        8426 bytes

Concurrency Level:      10
Time taken for tests:   50.289 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      8664000 bytes
HTML transferred:       8426000 bytes
Requests per second:    19.89 [#/sec] (mean)
Time per request:       502.890 [ms] (mean)
Time per request:       50.289 [ms] (mean, across all concurrent requests)
Transfer rate:          168.25 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       3
Processing:   131  502 112.9    501     884
Waiting:       41  413 116.4    451     597
Total:        131  502 112.9    501     884

Percentage of the requests served within a certain time (ms)
  50%    501
  66%    534
  75%    550
  80%    572
  90%    633
  95%    720
  98%    765
  99%    853
 100%    884 (longest request)

puma 结果

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        
Server Hostname:        127.0.0.1
Server Port:            9292

Document Path:          /c/11
Document Length:        8426 bytes

Concurrency Level:      10
Time taken for tests:   61.425 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      8620000 bytes
HTML transferred:       8426000 bytes
Requests per second:    16.28 [#/sec] (mean)
Time per request:       614.251 [ms] (mean)
Time per request:       61.425 [ms] (mean, across all concurrent requests)
Transfer rate:          137.04 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   385  613 102.6    608    1465
Waiting:      385  611 102.4    605    1465
Total:        385  613 102.6    608    1465

Percentage of the requests served within a certain time (ms)
  50%    608
  66%    650
  75%    676
  80%    693
  90%    735
  95%    783
  98%    831
  99%    869
 100%   1465 (longest request)

结果是 thin 的总时间比 puma 要少 10 秒

ruby 2.0 的测试结果? 据说 puma 比较适合 jruby 和 rubinius

thin 确实是没法在 jruby 下使用

结果是由 server 特性决定的,这不是靠不靠谱的问题。

话说大家的场景是怎么样的?还有优化问题需要解决?个人觉得库的稳定性压倒一切,基础库出 bug 会死人的。。

#1 楼 @ShiningRay 嗯,ruby2.0 测试结果

不过如果数据库长查询多,或后端有其它的网络阻塞场景。用 puma 还是比较不错的。不会像 thin 阻塞着导致一下个连接无法响应。

#4 楼 @linjunhalida 场景就是一个小 VPS 的小网站部署方案,比如 VPS 只有 256M 内存,或 512M 内存。

稳定性的话,thin 主要用到 eventmachine 这个库,稳定应该还可以.puma 无第三方依赖. 用 puma, 在开发环境中启用 Sinatra::Reloader,访问没几次就会出现栈错误.thin 到是没有。

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