- Practical DevOps
- Joakim Verona
- 423字
- 2021-07-16 09:48:07
Rolling upgrades
Another thing to consider when doing database migrations is what can be referred to as rolling upgrades. These kinds of deployments are common when you don't want your end user to experience any downtime, or at least very little downtime.
Here is an example of a rolling upgrade for our organization's customer database.
When we start, we have a running system with one database and two servers. We have a load balancer in front of the two servers.
We are going to roll out a change to the database schema, which also affects the servers. We are going to split the customer name field in the database into two separate fields, first name and surname.
This is an incompatible change. How do we minimize downtime? Let's look at the solution:
- We start out by doing a database migration that creates the two new name fields and then fills these new fields by taking the old name field and splitting the field into two halves by finding a space character in the name. This was the initial chosen encoding for names, which wasn't stellar. This is why we want to change it.
This change is so far backward compatible, because we didn't remove the name field; we just created two new fields that are, so far, unused.
- Next, we change the load balancer configuration so that the second of our two servers is no longer accessible from the outside world. The first server chugs along happily, because the old name field is still accessible to the old server code.
- Now we are free to upgrade server two, since nobody uses it.
After the upgrade, we start it, and it is also happy because it uses the two new database fields.
- At this point, we can again switch the load balancer configuration such that server one is not available, and server two is brought online instead. We do the same kind of upgrade on server one while it is offline. We start it and now make both servers accessible again by reinstating our original load balancer configuration.
Now, the change is deployed almost completely. The only thing remaining is removing the old name field, since no server code uses it anymore.
As we can see, rolling upgrades require a lot of work in advance to function properly. It is far easier to schedule upgrades during natural downtimes, if your organization has any. International organizations might not have any suitable natural windows to perform upgrades, and then rolling upgrades might be the only option.
- AngularJS Web Application Development Blueprints
- PyTorch Artificial Intelligence Fundamentals
- Apache Spark 2 for Beginners
- Getting Started with PowerShell
- Instant Typeahead.js
- 手把手教你學C語言
- Spring Boot Cookbook
- 微信小程序項目開發實戰
- 從Excel到Python:用Python輕松處理Excel數據(第2版)
- Learning Unity 2D Game Development by Example
- Android系統原理及開發要點詳解
- Orleans:構建高性能分布式Actor服務
- Machine Learning for Developers
- Java Web開發實例大全(基礎卷) (軟件工程師開發大系)
- QlikView Unlocked