TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Zero downtime migrations

187 pointsby KiranRao0about 3 years ago

11 comments

darkwaterabout 3 years ago
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 未加载
harryvederciabout 3 years ago
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 未加载
jbverschoorabout 3 years ago
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 未加载
antoncohenabout 3 years ago
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 未加载
fabianlindforsabout 3 years ago
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 :)
yakkomajuriabout 3 years ago
&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>
stalluriabout 3 years ago
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_junkabout 3 years ago
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.
tzahifadidaabout 3 years ago
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.
ewuhicabout 3 years ago
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.
jfk13about 3 years ago
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 未加载