一起来 - Mongrel---Faster Is Possible

来源:百度文库 编辑:神马文学网 时间:2024/10/02 16:49:42
Mongrel是一种快速的Http server for Ruby 她是纯Ruby完成的Http server,她的能力十分强大,同时支持Ruby On Rails,Og+Nitro, andCamping frameworks,你需要安装Ruby1.8.4
安装方法:(windows下)
1.使用gem安装
$ gem install win32-service (pick the most recent one)
$ gem install mongrel (pick the win32 pre-built)
$ gem install mongrel_service
2.开启服务器
$ mongrel_rails service::install -N myapp \
-c c:\my\path\to\myapp -p 4000 -e production
上面的步骤把mongrel加入到windows服务中了
$ mongrel_rails service::start -N myapp
----------------------
One moment, start pending
One moment, start pending
One moment, start pending
One moment, start pending
hi service started
----------------------
*这里hi是我的web app
服务器将在后台运行
这里也可以通过 我的电脑---管理---服务,来启动它
3.关闭服务(器)
$ mongrel_rails service::stop -N myapp
----------------------
There was a problem stopping the service:
当处理控制请求时,在服务中发生异常。
----------------------
*结束时出现错误,不过再次结束的时候出现:
----------------------
There was a problem stopping the service:
服务未启动。
----------------------
*说明服务已经结束
测试:
我这里对Webrick和Mongrel做了一个测试:
测试软件Web-CT,同时使用40次/s,持续10s的测试方式,测试结果如下
Webrick:
测试频率:40
测试次数:400
持续时间:10
成功次数:400
接收流量:3020800
平均流速:601
下载文件尺寸:7552
成功率:100%
平均响应时间:12571
Mongrel
测试频率:40
测试次数:400
持续时间:10
成功次数:400
接收流量:3020800
平均流速:329278
下载文件尺寸:7552
成功率:100%
平均响应时间:22
我们注意到平均流速和平均相应时间,我们可以看到他们的差距是惊人的。所以,赶快离开Webrick的世界吧。
当然,Webrick可能会在开发学习阶段给我们带来好处:)
使用WAS测试:
Webrick
Stress level(threads):50
Stress multiplier:1
Page Summary
Page                                  Hits        TTFB Avg    TTLB Avg    Auth     Query
==============================================
GET /index.html                 2335      309.99       369.99         No        No
Socket Connects:              2353
Total Bytes Sent (in KB):     445.78
Bytes Sent Rate (in KB/s):    7.43
Total Bytes Recv (in KB):     17774.31
Bytes Recv Rate (in KB/s):    296.17
Mongrel
Stress level(threads):50
Stress multiplier:1
Page Summary
Page                                   Hits      TTFB Avg      TTLB Avg    Auth      Query
==============================================
GET /index.html                 4899     74.40           178.57         No         No
Socket Connects:              4919
Total Bytes Sent (in KB):     931.92
Bytes Sent Rate (in KB/s):    15.53
Total Bytes Recv (in KB):     37073.90
Bytes Recv Rate (in KB/s):    617.72