- 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.
- 自制編譯器
- Effective C#:改善C#代碼的50個有效方法(原書第3版)
- Visual C++串口通信技術詳解(第2版)
- Ray分布式機器學習:利用Ray進行大模型的數據處理、訓練、推理和部署
- 人人都懂設計模式:從生活中領悟設計模式(Python實現)
- C++ 從入門到項目實踐(超值版)
- 零基礎學Python數據分析(升級版)
- Ext JS 4 Web Application Development Cookbook
- Rust Essentials(Second Edition)
- Extending Puppet(Second Edition)
- 編程可以很簡單
- OpenCV 3計算機視覺:Python語言實現(原書第2版)
- Microsoft Exchange Server 2016 PowerShell Cookbook(Fourth Edition)
- 算法精解:C語言描述
- Java算法從菜鳥到達人