TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Zero downtime migrations

187 点作者 KiranRao0大约 3 年前

11 条评论

darkwater大约 3 年前
If you are using MySQL I also recommend Percona&#x27;s Online Schema Change [1] which is basically a robust implementation of this post&#x27;s algorithm, handles more edge-cases, has been existing for at least 10 years now and works better out of the box with AWS RDS than Gh-ost. (if you have production experience on 100s of millions rows tables with Gh-ost on RDS please share your experience&#x2F;tricks, I&#x27;d love to hear them!)<p>[1] <a href="https:&#x2F;&#x2F;www.percona.com&#x2F;doc&#x2F;percona-toolkit&#x2F;3.0&#x2F;pt-online-schema-change.html" rel="nofollow">https:&#x2F;&#x2F;www.percona.com&#x2F;doc&#x2F;percona-toolkit&#x2F;3.0&#x2F;pt-online-sc...</a>
评论 #31270191 未加载
评论 #31273483 未加载
harryvederci大约 3 年前
Something I&#x27;m doing in my CV application is using 1 SQLite DB file per user.<p>When a user logs in, a check is done: &quot;Does this user&#x27;s DB file have the latest migration?&quot; If not, the migrations are applied. That way, you only get a slight delay as a user when a migration is needed. None of the other users their DB files are affected. More technical details are in the FAQ: <a href="https:&#x2F;&#x2F;withoutdistractions.com&#x2F;cv&#x2F;faq" rel="nofollow">https:&#x2F;&#x2F;withoutdistractions.com&#x2F;cv&#x2F;faq</a><p>In terms of the article: I&#x27;m only changing 1 tire at a time at 100mph, not all of them.<p>PS: I recently did a &quot;Show HN&quot; about the app, it got some interesting feedback: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31246696" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31246696</a>
评论 #31271569 未加载
评论 #31273524 未加载
评论 #31271513 未加载
jbverschoor大约 3 年前
I dunno.. people seem to like 0 downtime migrations, but really, for most companies a little bit of downtime or degraded functionality doesn&#x27;t matter. Most applications aren&#x27;t even large enough for the downtime to be more than a couple of minutes.<p>Having some scheduled downtime saves you a lot of complexity of writing, monitoring, and finalizing these migrations. It also makes it a lot easier to have a consistent state in terms of code+data.<p>The article doesn&#x27;t mention how to deal with different datamodels &#x2F; constraints etc.
评论 #31271625 未加载
评论 #31272080 未加载
评论 #31271532 未加载
评论 #31281600 未加载
antoncohen大约 3 年前
MySQL has some robust tooling in this space. Some of the tools use triggers to copy to a new table. GitHub&#x27;s gh-ost[1] is probably the state of the art, and uses the binary log stream to replicate the data.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;github&#x2F;gh-ost" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;github&#x2F;gh-ost</a>
评论 #31269812 未加载
fabianlindfors大约 3 年前
Anybody interested in this subject might also be interested in a tool for Postgres I’ve been working on, Reshape: <a href="https:&#x2F;&#x2F;github.com&#x2F;fabianlindfors&#x2F;reshape" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fabianlindfors&#x2F;reshape</a>. It aims to fully automate away all the pain and manual steps zero-downtime migrations normally requires :)
yakkomajuri大约 3 年前
&gt; Now the most challenging part: explaining to Product why their seemingly small request took 3x longer than expected. If it helps you can send them this article. Good luck!<p>We had to solve this problem in a way that also took our self-hosted users into account. Essentially &quot;changing Tires at 100mph&quot; in environments we don&#x27;t control. Still polishing it but will plug a post about it here if anyone finds it relevant:<p><a href="https:&#x2F;&#x2F;posthog.com&#x2F;blog&#x2F;async-migrations" rel="nofollow">https:&#x2F;&#x2F;posthog.com&#x2F;blog&#x2F;async-migrations</a>
stalluri大约 3 年前
I think PlanetScale folks have blogged well about how schema migration tools work and their traffic splitting, rewinding abilities are very nice.<p><a href="https:&#x2F;&#x2F;docs.planetscale.com&#x2F;learn&#x2F;how-online-schema-change-tools-work" rel="nofollow">https:&#x2F;&#x2F;docs.planetscale.com&#x2F;learn&#x2F;how-online-schema-change-...</a><p><a href="https:&#x2F;&#x2F;planetscale.com&#x2F;blog&#x2F;its-fine-rewind-revert-a-migration-without-losing-data" rel="nofollow">https:&#x2F;&#x2F;planetscale.com&#x2F;blog&#x2F;its-fine-rewind-revert-a-migrat...</a>
kasey_junk大约 3 年前
When I was first starting out writing applications it was very common for the DBA in charge of a database to require all writes to go to a stored procedure and all reads to go through views. It was at times onerous but it made migrations like these a snap. With most migrations&#x2F;rdms it could even be atomic.
tzahifadida大约 3 年前
I thought of another trick. Haven&quot;t tried it, should work though. Where applicable put tenants on multi schema. If the tables are now very small in comparison then a write lock is not that important. Simply migrate. Do a blue green deployment between code versions. Done.<p>One downside is the downgrade part. If you still want it you have to do it as in the article.
ewuhic大约 3 年前
Side Question - could anyone suggest a tool for db cloning in context of on-commit preview environments?<p>I am only aware of this tool: <a href="https:&#x2F;&#x2F;github.com&#x2F;postgres-ai&#x2F;database-lab-engine" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;postgres-ai&#x2F;database-lab-engine</a><p>But it looks like too much manual work to do.
jfk13大约 3 年前
Ah, it&#x27;s about databases... the title here immediately made me think of a much more hardcore &quot;migration&quot; effort: <a href="https:&#x2F;&#x2F;www.amusingplanet.com&#x2F;2019&#x2F;10&#x2F;an-incredible-move-indiana-bell.html" rel="nofollow">https:&#x2F;&#x2F;www.amusingplanet.com&#x2F;2019&#x2F;10&#x2F;an-incredible-move-ind...</a>
评论 #31272778 未加载