Heroku 部署流程到底是如何运作的?
当我将新版本的服务部署到 Heroku 时,到底会发生什么?
假设我现在有 N 个在线网络测功机,其中 M 个当前正在处理请求。
- 在新版本上线之前所有这些都关闭了吗?当前正在处理的任何待处理请求会发生什么情况?
- 有停机时间吗? (假设我只有一个无状态服务,没有任何迁移)
- 是否有一个用于执行自定义迁移的钩子(例如迁移数据库表)?
- 我是否可以启动运行新版本的 N 个服务器,让它们开始为请求提供服务,并仅在以前的 N 个服务器不再为任何请求提供服务时才将其关闭?
- 答案取决于堆栈/语言吗? (Aspen/Bamboo/Cedar、Ruby/Node.js/Java/...)
我没有任何关于此的官方文档,只是相反的帖子(有些人说热门不可能进行迁移,而 其他人说没有停机时间)。官方有关于部署过程和上述问题的详细信息吗?
When I deploy a new version of my service to Heroku, what happens exactly?
Suppose I have N web dynos online right now, M of them currently servicing requests.
- Do all of them shut down before the new version starts coming online? What happens to any pending requests currently being serviced?
- Is there downtime? (let's assume I just have a stateless service without any migrations)
- Is there a hook for doing custom migrations (e.g. migrate database tables)?
- Can I bring up N servers running the new version, have them start servicing requests, and bring the previous N servers down only once they're not servicing any requests?
- Does the answer depend on the stack/language? (Aspen/Bamboo/Cedar, Ruby/Node.js/Java/...)
I didn't any official documentation about this, just contrary posts (some saying hot migrations are not possible, while others say there is no downtime). Are there any official details about the deployment process and the questions above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是 Heroku 部署期间发生的情况(截至 2011 年 10 月 20 日*)[1]:
一般要点是,为了最大限度地减少任何可能的停机时间,您应该最大限度地减少应用程序的启动时间。
通过遵循仔细的迁移实践,可以推送新代码,然后在应用程序运行时进行迁移。
以下是 Rails 的示例: http://pedro.herokuapp.com/past/2011/7/13 /rails_migrations_with_no_downtime/
要最大程度地减少重新启动期间丢失的连接,请使用通过启动一个适当响应 SIGTERM 的网络服务器正常关闭(完成现有连接,不接受新连接)。较新版本的 thin 将正确处理 SIGTERM。
未来的改变。
仍在运行
Here is what happens during a Heroku deploy (current as of 10/20/2011*)[1]:
The general takeaway is that to minimize any possible downtime you should minimize the boot time of your app.
By following careful migration practices, it is possible to push new code and then migrate while the app is running.
Here's an example for Rails: http://pedro.herokuapp.com/past/2011/7/13/rails_migrations_with_no_downtime/
To minimize dropped connections during a restart, use a webserve that responds appropriately to SIGTERM by beginning a graceful shutdown (finish existing connections, dont take new ones). Newer versions of thin will handle SIGTERM correctly.
change in the future.
still running
我可以回答“是否有一个用于执行自定义迁移(例如迁移数据库表)的钩子?”这个问题的一部分。我通过编写一个 shell 脚本来处理运行迁移,该脚本在发出“git push heroku”后立即执行“heroku rake db:migrate”。我不知道是否还有更“钩子”的方法可以做到这一点。
I can answer "Is there a hook for doing custom migrations (e.g. migrate database tables)?" part of this question. I've handled running migrations by writing a shell script that does a "heroku rake db:migrate" immediately after I issue "git push heroku". I don't know if there is a more "hook" - y way to do that.