加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何对我的Rails应用程序的启动进行基准测试?

发布时间:2020-12-17 02:01:12 所属栏目:百科 来源:网络整理
导读:我把我的Rails应用程序放在Heroku上,现在我看到它的启动时间非常慢.我的意思是,当我第一次访问我的Heroku网站(使用浏览器)时,显示索引页面需要花费太多时间,但是当我之后浏览网站时,请求需要正常时间. 那么如何看待这个“第一次”请求需要花费这么多时间呢?
我把我的Rails应用程序放在Heroku上,现在我看到它的启动时间非常慢.我的意思是,当我第一次访问我的Heroku网站(使用浏览器)时,显示索引页面需要花费太多时间,但是当我之后浏览网站时,请求需要正常时间.

那么如何看待这个“第一次”请求需要花费这么多时间呢?

解决方法

这是正常的,因为你不支付你的动力,并且在一段时间之后第一个dyno会闲置.

http://devcenter.heroku.com/articles/dynos

Apps that have only 1 web dyno will be idled out after a period of inactivity. The web dyno will be shut down. When a request comes in to an idled app your web dyno will be automatically spun back up,causing a few second delay for this first request. Subsequent requests will perform normally.

Apps that have more than 1 web dyno are never idled out. Workers dynos are never idled out.

如果要查看发生了什么,可以使用该命令(从您的安装目录)

heroku logs

它将显示您的服务器的日志.

在我的临时环境中,如果我现在查询(当我的dyno空转时),我可以在日志中看到

2012-02-18T12:17:24+00:00 heroku[web.1]: Unidling
2012-02-18T12:17:24+00:00 heroku[web.1]: State changed from down to created
2012-02-18T12:17:24+00:00 heroku[web.1]: State changed from created to starting

[.....]
2012-02-18T12:17:42+00:00 heroku[router]: GET [...] dyno=web.1 queue=0 wait=0ms service=9ms status=200 bytes=0

=>我花了大约20秒来满足我的第一次请求.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读