Earlier quoted context omitted.
"A place I worked at had a symlink pointing to the app directory" This is the way to go. Have your root web directory be a symlink. EG. /var/www/app -> /code_[git_hash]/ You can whip through a thousand vms less than a second with this method. Connect, change the symlink. Other options: Pushing out a new code branch, reverting with git, launching new vms with reverted images, rsync'ing with overwriting -- is slower, a…
> There is no such thing as a database migration on prod. There is just adding columns. Code should work with new columns added at any point. If you can't alter a column, how do you prevent your database slowly rotting in terms of its design integrity?
Ask HN: How do you roll back production?
121–130 of 156 posts
Re: Ask HN: How do you roll back production?
#122Earlier quoted context omitted.
"A place I worked at had a symlink pointing to the app directory" This is the way to go. Have your root web directory be a symlink. EG. /var/www/app -> /code_[git_hash]/ You can whip through a thousand vms less than a second with this method. Connect, change the symlink. Other options: Pushing out a new code branch, reverting with git, launching new vms with reverted images, rsync'ing with overwriting -- is slower, a…
>There is no such thing as a database migration on prod. There is just adding columns. We have a DB schema that we not so affectionately refer to as the Standard Oil Octopus because of this methodology applied over ~20yr. I agree with you in the general case but eventually hard cuts have to be made or you will perpetuate the existence of all sorts of legacy spaghetti (not necessarily in the DB, but in all the other t…
Re: Ask HN: How do you roll back production?
#123Earlier quoted context omitted.
"A place I worked at had a symlink pointing to the app directory" This is the way to go. Have your root web directory be a symlink. EG. /var/www/app -> /code_[git_hash]/ You can whip through a thousand vms less than a second with this method. Connect, change the symlink. Other options: Pushing out a new code branch, reverting with git, launching new vms with reverted images, rsync'ing with overwriting -- is slower, a…
>There is no such thing as a database migration on prod. There is just adding columns. We have a DB schema that we not so affectionately refer to as the Standard Oil Octopus because of this methodology applied over ~20yr. I agree with you in the general case but eventually hard cuts have to be made or you will perpetuate the existence of all sorts of legacy spaghetti (not necessarily in the DB, but in all the other t…
Re: Ask HN: How do you roll back production?
#124Earlier quoted context omitted.
Correct. We 'mark' no longer used database objects for removal at some future date. And mark is really just add a ticket to be completed in the future.
Do you have a method to rollback database object removals if they cause problems?
This process lets you validate and rollback/recover if needed.
Re: Ask HN: How do you roll back production?
#125Earlier quoted context omitted.
Bahahaha, your tests really aren't ‘best’. Properly, if your code has an ‘if’, you need two tests, for the two branches. Same with every place the outcome may diverge. With this approach, it's basically impossible to botch the code unless something slips your mind while writing both the code and the tests. Otherwise, it's pretty much ‘deploy and go home.’
> Properly, if your code has an ‘if’, you need two tests, for the two branches. Same with every place the outcome may diverge. With this approach, it's basically impossible to botch the code if (x % 3 == 0) println "Fizz" if (x % 5 == 0) println "Buzz" There, solved it! And it works fine in all cases you told me to test (e.g. 3, 4, and 5), which means it's impossible I botched anything! Surely I nailed this interview…
Well, if you don't see other points where the input→output mapping can diverge (and rely on the client's requirements for that?), then no, you didn't nail it.
Re: Ask HN: How do you roll back production?
#126A place I worked at had a symlink pointing to the app directory, and a new version went to a new dir. This allowed us to do atomic deployments: code wasn't replaced while it's being run. A rollback, consequently, meant pointing that symlink to the older version. For the database, during a migration we didn't synchronize code with one version of the db. Database structure was modified to add new fields or tables, and…
Or could probably just use overlayfs or something like that.
Note that, while containers can give you COW, they shouldn't really be necessary for the files of the app. And with php-fpm, changing the app dir is faster than restarting containers: it's actually done via changing the Nginx config.
Re: Ask HN: How do you roll back production?
#127Assuming this is about web dev. Nowadays - flip a toggle in the admin. Deployments and releases are separated. Made a major blunder? In kubernetes world we do "helm rollback". Takes seconds. This allows for a super fast pipeline and a team of 6 devs pushes out like 50 deployments a day. Pre-kubernetes it would be AWS pipeline that would startup servers with old commits. We'd catch most of the stuff in blue/green phas…
> Nowadays - flip a toggle in the admin. Deployments and releases are separated. Would you mind explaining this a little further? How does the separation allow you to flip a switch in the admin?
Uploading new code to a server where the new-code is behind a disabled feature flag means the program hasn't changed. The feature flag can be enabled when it's suitable. (This could even be 'rolled out' to only a subset of users; e.g. testers, internal, 10% of users, etc.)
deploy = put the code on the server, release = enable the feature flags
Re: Ask HN: How do you roll back production?
#128Specifically, I tell Jenkins to deploy the commit hash that was last known good. Jenkins just deploys, and doesn't really know that it's a "roll back." Generally, going back to a known clean state should be easier, safer and relatively quick (DNS flip is fast, redeploy of old code is fast if your automation works well). In some cases changes to your data may make rolling back cause even more problems. I've seen that…
How do you find the commit hash that is the last known good? Looking through jenkins release logs, asking someone, something else?
Re: Ask HN: How do you roll back production?
#129Earlier quoted context omitted.
That's not really correct. Properly input space partitioned tests have something like 90 to 95 accuracy if properly written. The issues always come from people not wanting to add sufficient tests.
Does that mean that 1 in 20 deploys breaks, then?
Continous Integration is mostly about regression, so the new tests have less value than running old tests.
We tend to fix issues in production (bugs) by mandating a unit test with the failing issue to be written as part of the fix.
Re: Ask HN: How do you roll back production?
#130* Deploy new code in new VMs.
* Route some prod traffic to the new nodes.
* Watch the nodes misbehave somehow.
* Route 100% of the prod traffic back to old nodes (which nobody tore down).
Rollback complete.
In the case of normal deployment, 100% of prod traffic would eventually be directed to new modes. After a few hours of everything running smoothly, the old nodes would be spun down.