|
|
|
Ask HN: Database migration on production without downtime
|
|
9 points
by ainhu
2280 days ago
|
|
How do you handle database migration on production servers without downtime? We are currently struggling to find the right strategy to handle migrations of our database schemas without downtime. We are running a NodeJS application with a MongoDB on Kubernetes and can have thus pods of different versions running concurrently when deploying a new version (we currently perform rolling updates). Some options we have been considering: 1. Using an evolutionary database design (only adding fields to the schema) and having the newer version write both the old and new.
2. Extracting the DB repository to an external versionable service that reads/write from the DB and returns a different schema version depending on what application version requests an entity. Further suggestions are greatly appreciated! |
|
- all major databases, including MySQL, have an equivalent to ALTER ONLINE now. However, not all operations are covered, and you need to develop pre-tested procedures for small and large tables. If you can't predict how long an ALTER will take, then you're not prepared enough. (Typically under 400k narrow rows on SSD you don't even need ALTER ONLINE at ebb time.)
https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-op...
- there's lots of trigger-based tools, like pt-online-schema-change
https://www.percona.com/doc/percona-toolkit/3.0/pt-online-sc...
- using local SSD helps a lot. using EBS will be ugly for large tables. active master/passive master flipping might be helpful for hard disks.
- for large tables, you still want to make changes at ebb time. In the US, that's generally around 6 or 7 pm PST.
- experienced DBAs keep things simple and understandable. So the "evolutionary database design" and "failing forward" are recommended.
- data retention policies (say 18 months) help with mgmt.
- using tools like Ruby migrations is a special thing, so you need to look under the hood there.
Pro Tip: Phrases like "Extracting the DB repository to an external versionable service" give DBAs the willies. Sounds like a dangerous path to me.
Source: DBA.