Microservices Architecture (MSA) inspired by Service-Oriented Architecture (SOA) has gained immense popularity in the past few years [dragoni2017microservices]. With MSA, an application is designed as a set of business-driven microservices that can be developed, deployed, tested, and scaled independently [taibi2019monolithic]. Organizations adopt MSA due to better availability, scalability, productivity, performance, fault-tolerance, and cloud support compared with SOA or monolithic applications. It is argued that MSA can also help build autonomous development teams [taibi2019monolithic].
Microservices systems entail a significant degree of complexity at the design phase and runtime configurations from an architecture perspective [newman2020building]. Haselbock et al. [AR5] identified several design areas for microservices systems, such as application decomposition, microservices security, and communication. On the other hand, literature reviews (e.g., [waseemMSAdevops]), existing practices (e.g., [waseemMSAdesign]), and exploratory studies (e.g., [waseem2021nature]) indicate several challenges related to the design areas mentioned in [AR5], for instance, clearly defining the boundaries of microservices, addressing their security concerns, and managing the communication between a large number of microservices.
Both academia and industry have presented reusable solutions for microservices systems in the form of patterns and strategies. These patterns and strategies are currently distributed across different publications (e.g., scientific and grey literature). The practitioners need to navigate pattern to pattern (and strategy) until a suitable combination of patterns (and strategies) that can address the challenges is found. Moreover, the practitioners cannot find a holistic view of the patterns and strategies for a trade-off analysis (e.g., patterns influence Quality Attributes (QAs)). According to the recent studies (e.g., [waseemMSAdevops][waseem2021nature][waseemMSAdesign]), most of the design, development, monitoring and testing challenges are raised when application is decomposed into microservices. To this end, we present a decision model that assists practitioners in selecting appropriate patterns and strategies for decomposing applications into microservices. Decision models are a structured way of exploring the problem and solution space to achieve the design goal [AR7]. The proposed decision model has been developed based on a mini multivocal literature review through reviewing the scientific and grey literature.
2 Modeling Decision Model
The decision models in software architecture are used to map elements of the problem space to elements of the solution space [AR7]. The problem space represents functional and non-functional requirements, whereas the solution space represents design elements [AR7]. To create decision models for microservices systems, we represent the problem space as a set of QAs and the solution space as a set of microservices patterns and strategies. We developed the decision model for application decomposition because most of the design, development, monitoring, testing, and deployment challenges in microservices systems are rooted in this area ([waseemMSAdevops][waseem2021nature][waseemMSAdesign]). We collected required patterns, strategies, QAs, and impact of patterns on QAs for creating the decision model based on a mini multivocal literature review.
Fig. 1 presents the notations used in the decision model presented in this paper. We used Inclusive, Exclusive, and Parallel gateways of Business Process Model and Notation (BPMN) for indicating the decision flow. An MSA design area is represented through grey box. A circle is used to denote the start of a decision process. An Inclusive gateway is used to trigger more than one outgoing paths within a decision process. An Exclusive gateway is used to trigger one of the outgoing paths. In contrast, A Parallel gateway represents the multiple parallel outgoing paths within a decision process. We used rounded rectangle to represent the patterns and strategies belong to an MSA design area. A double-headed arrow shows a “complements” relationship between two patterns or strategies. An octagon and dashed arrow is used to represent the constraints of each pattern or strategy. Finally, plus (+) and minus (-) signs indicate the positive and negative impact of each pattern or strategy on the QAs.
3 Application Decomposition Decision Model
Monolithic applications need to be decomposed into small, independent, and loosely coupled microservices to achieve the benefits (e.g., improved scalability, independent deployment). There are several ways to break down an application into microservices. The patterns and strategies collected are used to create the application decomposition decision model (see Fig. 2). The decision process for application decomposition into microservices is based on the team size and impact of patterns and strategies on QAs. If the application needs to be decomposed into microservices for the team of 5-9 people to increase Availability, Scalability, Cohesion, Deployment, Performance, and Maintainability, we can use one among five illustrated patterns (see Fig. 2). In the following, we further explain the other conditions, impact on QAs, and constraints for each pattern.
|Decomposed by subdomains [richardson2018microservices] [AWS]||Define services corresponding to Domain-Driven Design (DDD) subdomains.|
|Decomposed by business capabilities [richardson2018microservices] [AWS]||Define services corresponding to business capabilities.|
|Service per team [richardson2018microservices] [AWS]||Break down the application into microservices that individual teams can manage.|
|Decomposed by transactions [AWS]||An application typically needs to call multiple microservices to complete one business transaction. To avoid latency issues, services can be defined based on business transactions.|
|Scenario analysis [tusjunt2018refactoring]||Identify the business capabilities by analyzing the nouns and verbs from given business scenarios.|
|Graph-based approach [kamimura2018extracting]||Identify microservices from the source code of existing monolithic applications by graph clustering and visualization techniques.|
|Data Flow-Driven (DFD) approach [li2019dataflow]||Follow a top-down approach in which data flow diagrams contain the business requirements that are later partitioned through a formal algebra algorithm for identifying microservices.|
To increase Flexibility, Granularity, Reliability, Reusability, Security, Functional suitability, and Portability, Decomposed by subdomains pattern can be used. This pattern guides practitioners in defining each microservice responsibility, boundaries, and relationships with other microservices. To successfully implement this pattern, practitioners need to understand the overall business (see Fig. 2). In contrast, if microservices need to be defined with respect to business capabilities, Decomposed by business capabilities pattern can be used. Normally, business capabilities are organized into a multi-level hierarchy and generate business value. This pattern improves the Granularity, Performance, and Security of microservices if the business capabilities are identified by understanding the client organization’s structure, purposes, and business processes. However, this pattern reduces Flexibility as the application design is tightly coupled with the business model. Another option that we can use for decomposing applications is Service per team pattern. This pattern enables practitioners to break applications into microservices that individual teams can manage. It also complements Decomposed by subdomains and Decomposed by business capabilities patterns. A constraint of Service per team pattern is that only one small team (e.g., 5-9 people) owns one microservice, meaning that each team independently develops, tests, deploys, and scales individual microservice. The teams also interact with other teams to negotiate APIs. Service per team pattern increases Availability, Scalability, Cohesion, Deployment, and Performance, and Maintainability. If the project is large and needs to hire more people, Service per team pattern negatively impacts the development cost of microservices.
Another exclusive pattern option in decomposition patterns is Decompose by transactions, in which applications are decomposed based on business transactions. Each business transaction carries one task, and each microservice has the functionalities for several business transactions (e.g., sales, marketing). This pattern allows grouping multiple microservices to avoid latency issues. Decompose by transactions pattern can help to improve Response time, Data consistency, and Availability of microservices. Meanwhile, decomposing applications based on transactions also increases Execution cost and Coupling of microservices due to multiple functionalities being implemented in one microservice. Another option to decompose an application is Scenario-based analysis which consists of several steps, such as developing scenarios, describing MSA, and evaluating scenarios. During the evaluation process of scenarios, practitioners identify the microservices and interactions between them. This pattern is appropriate if practitioners have enough time to develop and describe the scenarios and MSA, respectively. This strategy can also be used to identify the business capabilities of systems by analyzing the nouns and verbs from given business scenarios. The identified nouns represent the microservices, and the verbs describe the relationship among them. While this strategy increases Scalability, Performance and Coupling could be compromised because of the imprecise boundaries of microservices.
Suppose that the team size is not defined for designing and developing microservices, and we need to identify the microservices from the code of legacy applications. In that case, we can choose Graph-based approach. This approach uses the SArF clustering algorithm to decompose the system for comprehension [kobayashi2013sarf] and the city metaphor techniques for visualizing the system structure [kamimura2018extracting]. Graph-based approach helps to identify microservices from the source code of existing monolithic applications. The use of this approach increases the Reusability of the existing code. Graph-based approach also visualizes the extracted microservices and their relationships along with the structure of the whole system. Hence, it also increases the Understandability about the MSA design. Finally, if the team size is not defined and applications need to be decomposed by using DFDs, in that case, Data flow-driven approach can be used, which consists of several steps, such as eliciting and analyzing the business requirements for identifying use cases and business logic specifications, creating fine-grained DFDs, identifying the dependencies between processes and datastores, and identifying microservices by clustering processes and related data stores. Data flow-driven approach increases Availability, Scalability, and Flexibility. In contrast, it decreases Performance and Reusability mainly because of complex DFDs.
4 Threats to Validity
The threats to construct validity are related to taking correct operational measures for collecting the data in this study. One potential threat is the inadequate use of the primary constructs of the decision model (i.e., MSA patterns and strategies, QAs, impact of the patterns on QAs). To mitigate this threat, we adopted the following operational measures: (i) we conducted a pilot search to ensure the correctness and appropriateness of the search terms, (ii) we used eight databases (i.e., ACM Digital Library, IEEE Explore, Springer Link, Science Direct, Wiley Online, Engineering Village, Web of Science, and Google Scholar) in software engineering research for retrieving the scientific studies, and (iii) we used Google for searching the grey literature. Additionally, we followed the guidelines [Garousi2019] to review and extract data from the scientific and grey literature.
The threats to internal validity represent circumstances that could influence the results obtained from the research. We tried to mitigate this threat through collaborative work between the authors of this work. Regarding the collaborative work, one author proposed the decision model and the rest of the authors contributed to improving the models based on their knowledge and expertise.
5 Related Work
Decision Models for Architecting Microservices Systems: The study in [AR3] examines existing literature and provides guidance models for microservices discovery and fault tolerance. The study in [AR4] reports decision guidance models about generating, processing, and managing monitoring data, and disseminating monitoring data to stakeholders in the process automation domain. On the other hand, the study in [AR2] analyzes the strategies and provides guidelines to support architects in selecting suitable frontend architecture(s) for microservices systems.
Practitioners’ Perspectives and Recommendations for Architecting Microservices Systems: The research in [AR1] derives a formal architecture decision model containing 325 elements and relations that can help to reduce the (i) efforts needed to understand the architectural decisions and (ii) uncertainty in the design process. An empirical study in [AR5] interviewed 10 microservices experts to find out the answers to (i) which design areas are relevant for microservices, (ii) how important they are, and (iii) why they are important.
Decision Models for Architectural Patterns Selection: The study [AR5] proposes a decision model that assists developers and architects in selecting appropriate patterns for blockchain-based applications. In a similar study [AR7], the authors present decision models for cyber-foraging systems that map functional and non-functional requirements to architectural tactics for designing and developing cyber-foraging systems.
Conclusive Summary: Our review of the related work suggests that there is a lack of research on decision models that can leverage patterns and strategies as reusable knowledge to address specific design area of microservices systems (i.e., application decomposition). To the best of our knowledge, our proposed decision model that supports decomposing applications into microservices is not covered in any existing studies. This decision model also provides an initial foundation to the research and practice in pattern-based architecting of microservices systems.
The paper proposes a decision model for selecting patterns and strategies to decompose applications into microservices. The proposed model is constructed by reviewing scientific and grey literature. The decision model provides MSA patterns, strategies, and their impact on QAs for selecting patterns and strategies in decomposing applications into microservices. In the next step, we aim to (1) propose decision models for other design areas, e.g., microservices security, communication, and service discovery, (2) validate the proposed decision models in an industrial setting, and (3) develop a recommendation system for selecting patterns and strategies for microservices systems.
This work has been supported by the National Key R&D Program of China under Grant No. 2018YFB1402800 and the NSFC under Grant No. 62172311.