官术网_书友最值得收藏!

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:

  1. 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.

  2. 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.
  3. 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.

  4. 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.

主站蜘蛛池模板: 鹤壁市| 高雄县| 乌兰察布市| 晋中市| 阿克| 赣州市| 台安县| 喀什市| 万州区| 内江市| 桂平市| 临武县| 丹江口市| 开原市| 喀喇沁旗| 祁东县| 宜阳县| 伊川县| 雅江县| 宜君县| 潜山县| 独山县| 霍州市| 景德镇市| 万年县| 名山县| 大洼县| 凤城市| 承德市| 扬中市| 烟台市| 贵定县| 遵化市| 澎湖县| 汉沽区| 阿拉尔市| 洛川县| 观塘区| 晋城| 中宁县| 银川市|