Microservice Patterns - 2.2 Defining an application's microservice architecture


Reference  

3 steps:
  1. Identify system operations
  2. Identify services
  3. Define services APIs and collaborations

Step1: Identifying system operations 
  1. Create a high level domain model
  2. Define system operations



Step 2: Identity services
  • Define services corresponding to business capabilities
  • Organize services around domain-driven design subdomains
  • Organize services around business concepts rather than technical concepts

Defining services by applying the Decompose by sub-domain pattern
Decomposition guidelines
  1. SINGLE RESPONSIBILITY PRINCIPLE:  A class should have only one reason to change
  2. COMMON CLOSURE PRINCIPLE:  The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package. ( We can apply CCP when creating a microservice architecture and package components that change for the same reason into the same service.)

Obstacles to decomposing an application into services
  • Network latency
  • Reduced availability due to synchronous communication
  • Maintaining data consistency across services
  • Obtaining a consistent view of the data
  • God classes preventing decomposition
God classes
" A god class typically implements business logic for many different aspects of the application. It normally has a large number of fields mapped to a database table with many columns. Most applications have at least one of these classes, each representing a concept that’s central to the domain: accounts in banking, orders in e-commerce, policies in insurance, and so on. "

Defining service APIs
A service API operation exists for one of two reasons: 
  • some operations correspond to system operations. They are invoked by external clients and perhaps by other services.
  • The other operations exist to support collaboration between services. These operations are only invoked by other services.
  1. ASSIGNING SYSTEM OPERATIONS TO SERVICES
  2. DETERMINING THE APIS REQUIRED TO SUPPORT COLLABORATION BETWEEN SERVICES





沒有留言:

張貼留言

別名演算法 Alias Method

 題目 每個伺服器支援不同的 TPM (transaction per minute) 當 request 來的時候, 系統需要馬上根據 TPM 的能力隨機找到一個適合的 server. 雖然稱為 "隨機", 但還是需要有 TPM 作為權重. 解法 別名演算法...