Heroku - 旋转起来
我有一个部署到 Heroku 的网站。这是一个低流量站点,因此如果几个小时内没有人访问它然后再访问它,则加载大约需要 5-10 秒。对该网站上其他页面的任何其他请求都会快速加载。如果我完全退出该网站并在几分钟后回来查看,它也会很快恢复。
只有当它闲置几个小时时,旋转时间才会明显。 还有其他人遇到这个问题吗?如果是这样,您是如何解决这个问题的。
另外,在讨论这个主题时,Google App Engine 是否也会发生同样的情况?我目前只是尝试这些应用程序托管平台,所以我对技术/语言没有任何偏好。
I have a site that I deployed to Heroku. It's a low traffic site so if nobody goes to it for a couple hours and then go to it, it will take about 5-10 seconds to load. Any other requests to other pages on that site loads up fine quickly. If I exit the site entirely and check back in a few minutes later, it also comes back up quickly.
It's only if it's left idle for a couple hours that the spin up time is noticeable. Does anyone else have this issue? If so, how did you fix it.
Also while on the topic, does the same thing happen with Google App Engine? I'm currently just trying out these app hosting platforms so I don't really have any preference for technologies/languages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您不想为 Pingdom 付费,可以尝试开源替代方案:Pinger
https://github.com /austinthecoder/pinger
If you don't want to pay for Pingdom, you can try the open source alternative: Pinger
https://github.com/austinthecoder/pinger
“解决”此问题的最快方法是确保您的网站始终正常运行。设置一个 pingdom 帐户 (http://www.pingdom.com/),每隔几分钟就会对您的网站进行 ping 操作,以保持其活力。
我有一条特殊的路线
myapp.com/keep_alive
,它除了在没有缓存的情况下命中 Rails 堆栈之外什么也不做。希望这有帮助!
Quickest way to "fix" this problem is to make sure your site is always up. Set up a pingdom account (http://www.pingdom.com/) which will ping your site every few minutes just to keep it alive.
I have a special route
myapp.com/keep_alive
which does nothing except hit the rails stack without caching.Hopefully this helps!
您碰巧以“免费计划”托管它吗?只有 1 个测功机?
如果是这样,您遇到的可能是 Dyno Idling。您可以增加测功机的数量,以便您的应用程序“始终在线”
Do you happen to be hosting it with the 'free plan', ie. only with 1 dyno?
If so, what you experience might be a Dyno Idling. You can increase the number of the dynos so that your app is 'always-on'
据我了解,Heroku 公开了这种行为。
对于免费网站托管,一个 Heroku 'Dyno' 专用于您的网站,如果 dyno 在一段时间内不活动,那么资源将被重定向到其他地方,当您在这段时间之后尝试访问该网站时,系统必须请求一个戴诺回来了。
您可以通过支付额外的测功机费用来防止这种情况发生,这将与您的网站保持一致,或者您可以使用自动脚本定期自己访问该网站。
From what I understand Heroku makes public this behaviour.
For free site hosting, one heroku 'Dyno' is dedictaed to your site, if the dyno is inactive for a period of time then the resource will be redirected elsewhere, when you try access the site after this time the system has to go request a Dyno back.
You can prevent this by paying for extra dyno's which will stick with your site or you can visit the site on a regular basis yourself with a automated script.
为了减少这个时间,你能做的最好的事情就是尽量减少蛞蝓的大小。这包括删除任何 PSD 或 AI 图像资源、删除 PDF 以及最小化宝石集等步骤。有关更多信息,请参阅:http://devcenter.heroku.com/articles/slug-size。作为参考,我的应用程序通常可以在一秒左右的时间内启动。
The best thing you can do to decrease this time is to minimize the size of your slug. This includes steps like deleting any PSD or AI image assets, removing PDFs, and minimizing your gem set. For more information see: http://devcenter.heroku.com/articles/slug-size. As a reference, my applications can usually spin up in under around one second.