Hands-On Docker for Microservices with Python
上QQ阅读APP看书,第一时间看更新

The divide approach

If the system is well structured, maybe some parts of it can be cleanly split into its own system, maintaining the same code.

In this case, creating a new service is more an exercise of copy-pasting and wrapping it around with the minimal amount of code to allow it to be executed independently and to interoperate with other systems, in other words, to structure its API around HTTP requests to have a standard interface.

If this approach can be used, it means that the code was already quite structured, which is fantastic news.

The systems that are called to this part will also have to be adapted to make the call, not to internal code, but through HTTP calls. The good part is that this can be done in a few steps:

  1. Copy the code into its own microservice and deploy it.
  2. The old calling system is using the old embedded code.
  3. Migrate a call and check that the system is working fine.
  4. Iterate until all old calls are migrated to the new system.
  5. Delete the divided code from the old system.

If the code is not so cleanly structured, we will need to change it first.