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

Identifying candidates for microservices

The top-most challenge in migrating from a monolithic application to microservices is to identify the right candidates for microservices. A well structured and modularized monolithic application already has well-defined boundaries (bounded contexts) that can help disintegrate the application into microservices. For example, the User, Orders, and Interest modules already have well-defined boundaries and are good candidates to create microservices for. If the application does not have well-defined boundaries, the first step is to refactor the existing application to create such bounded contexts for microservices. Each bounded context must be tied to a business capability for which a service can be created.

Another approach in identifying the right candidates for microservices is to look at the data access patterns and associated business logic. If the same database is being updated by multiple components of a monolithic application, then it makes sense to create a service for the primary component with associated business logic that manages the database and makes it accessible to other services via APIs. This process can be repeated until databases and the associated business logic are managed by one and only one service that has a small set of responsibilities, modeled around a business capability.

For example, a monolithic application consisting of User, Interest, and Orders components can be migrated into microservices by picking one component at a time and creating a microservice with an isolated database, as shown in the preceding diagram. To start with, first pick the one with the least dependency, the User module, and create the User Service service around it. All other components can now talk to this new User Service for User Management, including authentication, authorization, and getting user profiles. Next, pick the Orders module based on the least dependency logic, and create a service around it. Finally, pick the Interest module as it is dependent on both the User and Orders modules. Since we have the databases isolated, we can also swap out the database for Interest with maybe a graph database that is efficient to store and retrieve user interests due to its inherent capability of storing relationships as a graph.

In addition to organizing your microservices around business capabilities and database access patterns, look for common areas, such as a uthentication, authorization, and notification, that can be perfected once as a service and can be leveraged by one or more microservices later.
主站蜘蛛池模板: 双流县| 方山县| 长阳| 福州市| 临江市| 林周县| 辽源市| 苍南县| 民和| 洪洞县| 开平市| 阳城县| 杭锦旗| 岐山县| 富顺县| 云浮市| 宁国市| 太仆寺旗| 台北县| 凤城市| 孝义市| 迁安市| 杂多县| 大新县| 邯郸县| 新乡市| 邛崃市| 平定县| 海阳市| 乌兰察布市| 龙南县| 乌鲁木齐市| 登封市| 碌曲县| SHOW| 安国市| 固原市| 泊头市| 乌鲁木齐市| 嘉祥县| 平塘县|