Poor deployments can easily be rectified. Below is how you can ensure this.
Your application was deployed 4 minutes ago. Errors are increasing and a customer has just contacted support.
What do you then?
Usually people analyse logs to find a solution. Whilst this may seem the right course of action, it is not the most efficient way of returning to normality for your users.
Roll back and then analyse
Google’s Site Reliability Engineering (SRE) book highlights this in the section about analysis. Despite the urge to rapidly analyse and identify the root cause of a large disruption, you should in fact suppress this desire and initially prevent further issues. Until then you are not assisting anybody. In addition, the appendix on best practice for services within the book emphasises that, if an unforeseen issue occurs following a deployment, you should roll back first and then analyse. This allows a swift return to normality.
Google Cloud also has a blog post about release processes. Like Google, they regularly roll back. Should they determine that a new release is not behaving as intended, they roll back and then analyse.
This is logical. As a process, rolling back is well understood and produces predictable outcomes. In contrast, analysing an active issue can prove time consuming – taking anywhere between 10 minutes and 3 hours. Therefore, firstly implement the definite method of rolling back. Then, having returned to normality, carry out the less certain analysis task.
Elements for successful rollback
In order for rollback to be effective it must be rapid and uneventful. There are several factors to consider:
Previous release availability
If during a rollback you have to compile the previous release from Git, you will not know its trustworthiness until least desirable – namely when the production environment is offline.
Process simplicity
Should a rollback involve consulting a wiki and coordinating 3 people, there will be some reluctance to carry it out. Again, time is lost here.
Database compatibility
Often overlooked, simply rolling back code does not reverse a database migration. For example, if release 42 removes a column but release 41 still accesses it, then rolling back will cause the application to fail again. Typically, the solution is to use the expand and contract technique (also referred to as parallel change). Firstly, introduce the new column. Next, deploy code compatible with both the original and updated database structure. Finally, in a future release, delete the old column. Furthermore, the Google Cloud blog post indicates that if a database schema is compatible with both versions then you can roll back to the earlier version, without needing to also roll back the database schema.
Finally, you must confirm that everything functions correctly. Assess error levels and service health post rollback. Just because a deployment has been completed, does not necessarily mean that the application is healthy.
Assessing your set up
Choose a test service. Implement a minor and innocuous update. Roll this back and measure how long it takes to move from the decision to make to successfully returning to a healthy state. Then ask a colleague (who did not create your pipeline) to undertake the same. If either of you takes in excess of a few minutes, or requires assistance, then you have identified an area for improvement.
To improve this, ensure previous releases are accessible. Streamline your rollback process. And include the query "does this work with the previous release?" in your migration analysis list.
Rolling back in Optivian
Optivian provides immediate rollback functionality for each application that you deploy. Should a deployment be problematic, you revert to the last correct version rather than frantically recompiling. Note though, that unlike recompiling, rollback does not reverse the impact of a deployment on your data. Thus, the above guidance for migrations is applicable irrespective of the platform you use.
How swiftly could your team revert to the last successful release today?
References
Google SRE Book – Effective Troubleshooting: https://sre.google/sre-book/effective-troubleshooting/
Google SRE Book – Appendix B – Best Practices for Production Services: https://sre.google/sre-book/service-best-practices/
Google Cloud blog – Reliable releases and rollbacks: https://cloud.google.com/blog/products/gcp/reliable-releases-and-rollbacks-cre-life-lessons/
Martin Fowler – Parallel Change: https://www.martinfowler.com/bliki/ParallelChange.html
Optivian is an integrated cloud platform. For further information visit https://optivian.cloud
Top comments (1)
Quick poll: how long does a rollback take on your setup today? Reply with 1 for under 5 minutes, 2 for 5 to 30 minutes, or 3 for no idea.