Chapter IdentifyingMicroservicesUsingF
Chapter IdentifyingMicroservicesUsingF
Chapter IdentifyingMicroservicesUsingF
net/publication/327229270
CITATIONS READS
17 1,092
4 authors, including:
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Bo Liu on 28 November 2018.
1 Introduction
The microservices architecture style is rising fast as it has many advantages over
other architectural styles such as scalability (fine-grained, independently scal-
able), improved fault isolation (and thus resilience), and enhanced performance.
Hence, many companies are using this architectural style to develop their sys-
tems; for example, Netflix, Amazon, eBay, and Uber. The microservices architec-
ture is an approach for developing an application as a set of small, well-defined,
cohesive, loosely coupled, independently deployable, and distributed services.
Microservices interact via messages, using standard data formats and proto-
cols and published interfaces using a well-defined lightweight mechanism such
as REST [9]. An important aspect of this architecture is that each microservice
owns its domain model (data, logic, and behavior). Related functionalities are
c Springer Nature Switzerland AG 2018
X. Feng et al. (Eds.): SETTA 2018, LNCS 10998, pp. 50–65, 2018.
https://doi.org/10.1007/978-3-319-99933-3_4
Identifying Microservices Using Functional Decomposition 51
combined into a single business capability (called bounded context), and each
microservice implements one such capability (one or several services) [24]. The
microservices architecture assists in tackling the complexity of large applications
by decomposing them into small pieces, where each component resides within
its own bounded context.
This architecture also enables traceability between the requirements and the
system structure, and thus only one microservice has to be changed and rede-
ployed in order to update a domain [10].
The development of the microservices architecture aims to overcome short-
comings of monolithic architecture styles, where the user interface, the business
logic, and the databases are packaged into a single application and deployed
to a server. Whereas deployment is easy, a large monolithic application can
be difficult to understand and to maintain, because once the system evolves,
its modularity is eroded. Besides, every change causes the redeployment of the
whole system.
Two important issues which are favored by the microservices community as
keys to building a successful microservices architecture are the functional decom-
position of an application and the decentralized governance (i.e., each service usu-
ally manages its unique database). One of the big challenges in designing the
microservices architecture is to find an appropriate partition of the system into
microservices [28]. For example, the microservice architecture can significantly
affects the performance of the system [20]. It seems reasonable that each service
will have only a very limited set of responsibilities, preferable only one—the single
responsibility principle [27]. Determining the microservice granularity influences
the quality of service of the microservice application [16] and also the number of
microservices. Nevertheless, there is a lack of systematic approaches that decide
and suggest the microservice boundaries as described in more detail in the follow-
ing section. Hence, microservices design is usually performed intuitively, based on
the experience of the system designers. However, providing an inappropriate par-
tition into services and getting service boundaries wrong can be costly [29].
In this paper we describe a systematic approach to identify microservices in
early design phase. We identify the relationships between the required system
operations and the state variables that those operations read or write. We then
visualize the relationships between the system operations and state variables, thus
we can recognize clusters of dense relationships. This provides a partition of the
system’s state space into microservices, such that the operations of each microser-
vice access only the variables of that microservice. This decomposition guarantees
strong cohesion of each microservice and low coupling between services.
The remainder of the paper is organized as follows. The state of the art
is discussed in Sect. 2. We use the CoCoME [32] case study to motivate and
demonstrate our approach; in Sect. 3 we present the CoCoME trading system.
Our approach for identifying microservices is described in Sect. 4. Systems evolve
over time, and in Sect. 5 we describe the KAMP approach for change impact
analysis which we will use for system maintenance. In Sect. 6, we evaluate our
approach. We conclude in Sect. 7.
52 S. Tyszberowicz et al.
modeling and evolution [18]. The example includes processing sales at a single
store of the chain, e.g. scanning products or paying, as well as enterprise-wide
administrative tasks, e.g. inventory management and reporting.
The system specification includes functional requirements for: selling prod-
ucts, ordering products from providers, receiving the ordered products, showing
reports, and managing the stocks in each store. The specification is informal, and
is given in terms of detailed use cases (in the format proposed by Cockburn [5]).
In the following, we provide an excerpt of the use cases of CoCoME, as depicted
in Fig. 1. A fully detailed description can be found in [32].
– Process Sale: this use case detects the products that a customer has purchased
and handles the payment (by credit or cash) at the cash desk.
– Order Products: this use case is employed to order products from suppliers.
– Receive Ordered Products: this use case describes the requirement that once
the products arrive at the store, their correctness have to be checked and the
inventory has to be updated.
– Show Stock Reports: this use case refers to the requirement of generating
stock-related reports.
– Show Delivery Reports: calculate the mean times a delivery takes.
– Change Price: describes the case where the sale price of a product is changed.
Fig. 1. The UML use case diagram for the CoCoME system.
4 Identifying Microservices
The proposed analytical approach to identify microservices described in this
section is based on use case specification of the software requirements and on a
functional decomposition of those requirements. To employ the suggested app-
roach, we first need to create a model of the system. This model consists of
a finite set of system operations and of the system’s state space. System oper-
ations are the public operations (methods) of the system; i.e., the operations
that comprise the system’s API and which provide the system response to exter-
nal triggers. The state space is the set of system variables which contain the
information that system operations write and read.
54 S. Tyszberowicz et al.
relationships that are weakly connected to other clusters.3 Each such cluster
is considered a good candidate to become a microservice, because:
1. The amount of information it shares with the rest of the system is small, thus
it is protected from changes in the rest of the system and vice versa—this
satisfies the low coupling requirement.
2. The internal relationships are relatively dense, which in most cases indicates
a cohesive unit of functionality, satisfying the demand for strong cohesion.
3
A clustering of a graph G consists of a partition of the node set of G.
56 S. Tyszberowicz et al.
that occur as the system evolves, is one of many serious problems that con-
front today’s software developers. . . . we have developed an automatic technique
to decompose the structure of software systems into meaningful subsystems.
Subsystems provide developers with high-level structural information that helps
them navigate through the numerous software components, their interfaces, and
their interconnections”.
Finding the clusters at the source code level definitely helps to understand
the structure of the system. But it may be the case that the design is bad
with regard to coupling and cohesion. Correcting this once the code exists is
sometimes a very difficult task. Using clustering before the code exists, as done
in our approach, enables to develop software that is of higher design quality. It
is also easier than to maintain the software, for example with tools like KAMP,
as elaborated in Sect. 5. Moreover, having both the operation/relation table and
the clustering that has been obtained using this table, traceability is much easier.
Suppose, for example, that the user has to change a function; then she can easily
recognize in which component this function is implemented.
APIs and Databases. For each identified microservice we define its API and its
data storage. The API of the microservice (cluster) is provided by the union
Identifying Microservices Using Functional Decomposition 57
of the system operations which write into the state variables belonging to the
cluster that has been identified based on the visualization process. When a sys-
tem operation of another cluster reads information from the current cluster, a
getter method is added to the API of the current cluster; i.e., the access is only
through a published service interface. For example, the operation identifyItem
is part of the API of the Sale microservice (see the right hand side of Fig. 2).
Since identifyItem needs to read the product state variable of the ProductList
microservice, the getProduct operation is added to ProductList’s API.
There are two basic approaches regarding using databases for microservices.
(i) Hasselbring and Steinacker [17] propose the share nothing approach according
to which each microservice should have its own database. The advantages of this
approach is higher speed, horizontal scalability, and improved fault-tolerance.
One can also use a polyglot persistence architecture, where for each service the
best suited type of database is chosen. However, this approach is at the price of
data consistency, since consistency may only be eventual consistency (see [37]),
and problems are dealt with by compensating operations. (ii) Yanaga [38] as well
as Lewis and Fowler [24] claim that information can be shared. Yanaga argues
that since a microservice is not an island, the data between services has to be
integrated. That is, a microservice may require information provided by other
services and provides information required by other services.
We agree that services sometimes need to share data. Nevertheless, this shar-
ing should be minimal, to make the microservices as loosely coupled as possible.
In our approach we analyze each created cluster. The information that needs to
be persistent is found in the various clusters. If needed, we add to the cluster
(i.e., microservice) a database that contains the persistent data that is private
to this specific service. Of course it might be that the persistent data is located
in different clusters. In this case we may end up with several microservices that
contain data that is needed by other services. We guarantee that those databases
are accessible only via the API of the services that contain them; i.e., no direct
database access is allowed from outside the service.
6 Evaluation
In this section, we exemplify our approach based on the CoCoME community
case study [32] and evaluate our results.
Case Study: Starting with the use case specification of CoCoME, we identify
the system operations as well as their state variables. Table 1 shows the opera-
tion/relation table that has been created based on this information. This table
is then visualized as a graph, shown on the left hand side of Fig. 2. Based on the
graphical representation we have identified four major clusters which are candi-
dates to become microservices: ProductList, Sale, StockOrder, and Reporting; see
the right hand side of Fig. 2. In this way we have achieved a meaningful partition
into clusters, where each cluster has high cohesion and the coupling between the
clusters is low. Each of the four identified microservice candidates (clusters) is
responsible for a single bounded context in a business domain [10]. As can be
seen on the right hand side of Fig. 2, the microservices are not totally indepen-
dent. The communication between the microservices is implemented using REST
APIs [29].
Note that the emphasize in our approach is on identifying microservices that
deal with one business capability, rather than minimizing the microservices size;
this conforms to [6]. Moreover, as stated in [6], a clear cohesion based on a
high number of dependencies indicates the need for a single microservice. This
Identifying Microservices Using Functional Decomposition 59
– Identify business domain objects. For example, the CoCoME domain objects
includes Order, Commodity, Transaction, Payment, etc. The aim of this prin-
ciple is to find those microservices that correspond to one domain object.
This process was done by analyzing the use case descriptions and building a
conceptual class model [3].
– Identify special business. This is the case that a business process spans mul-
tiple domain objects, and then an independent microservice is designed.
– Reuse. Business processes that are frequently called may be detached from
the object and designed as a single microservice. Accordingly, if a constructed
microservice is seldom used or difficult to be implemented separately, it can
be attached to some object microservice or other microservices.
The team used the rCOS approach [4] to analyze the requirements and design
the microservices. The process can be summarized as follows: identify the use
4
For the implementations see https://github.com/cocome-community-case-study.
Identifying Microservices Using Functional Decomposition 61
cases (this step was not needed, as brief descriptions of the use cases specifi-
cations have been provided); construct the conceptual class diagram and use
case sequence diagrams; for each use case operation write contracts in terms of
its pre- and post-conditions. Those artifacts have formed a formal requirements
model; analysis can then be applied to verify consistency and correctness [4].
The CoCoMe requirements have been analyzed and validated for consistency
and functional correctness using the AutoPA tool [25]. It was a matter of days
for the students to design the microservices architecture of the system.5
– ProductList: Managing the products that are stored in the trading system.
– Sale: Handling a sale in the trading system.
– StockOrder : Managing a stock order of products.
– Reporting: Creating a report of the delivered products.
5
The implementation created by this group of students can be found in http://cocome.
swu-rise.net.cn/.
62 S. Tyszberowicz et al.
op8
op9 op10 op11 op12
op6 op7
op1 op2 op3 op4 op5
Gateway
7 Conclusion
We proposed a systematic and practical engineering approach to identify
microservices which is based on use-case specification and functional decom-
position of those requirements. This approach provides high cohesive and low
coupled decomposition. To evaluate our approach, we have compared the results
to three independent implementations of the CoCoME system. The evaluation
give us reasons to believe in the potential of our approach. We will involve other
kind of systems in the evaluation. Doing this we will also examine the scalability
of our approach. We believe it is scalable, since the tools that create the diagrams
and suggest decompositions are quite fast and can work on large graphs [11].
64 S. Tyszberowicz et al.
Acknowledgment. This work was supported by the DFG (German Research Foun-
dation) under the Priority Programme SPP1593, and the Key Laboratory of Safety-
Critical Software (Nanjing University of Aeronautics and Astronautics) under the Open
Foundation with No. NJ20170007. We would like to thank Kang Cheng, Guohang Guo,
Yukun Zhang, Nils Sommer, and Stephan Engelmann who worked on the development
of the various CoCoME systems. We also thank the anonymous reviewers for their
careful reading and their many insightful comments and suggestions. Their comments
helped to improve and clarify this paper.
References
1. Abbott, R.J.: Program design by informal english descriptions. Commun. ACM
26(11), 882–894 (1983)
2. Baresi, L., Garriga, M., De Renzis, A.: Microservices identification through inter-
face analysis. In: De Paoli, F., Schulte, S., Broch Johnsen, E. (eds.) ESOCC 2017.
LNCS, vol. 10465, pp. 19–33. Springer, Cham (2017). https://doi.org/10.1007/978-
3-319-67262-5 2
3. Chen, X., He, J., Liu, Z., Zhan, N.: A model of component-based programming. In:
Arbab, F., Sirjani, M. (eds.) FSEN 2007. LNCS, vol. 4767, pp. 191–206. Springer,
Heidelberg (2007). https://doi.org/10.1007/978-3-540-75698-9 13
4. Chen, Z., et al.: Refinement and verification in component-based model-driven
design. Sci. Comput. Program. 74(4), 168–196 (2009)
5. Cockburn, A.: Writing Effective Use Cases. Addison-Wesley, Boston (2000)
6. de la Torre, C., et al.: .NET Microservices: Architecture for Containerized .NET
Applications. Microsoft (2017)
7. De Santis, S., et al.: Evolve the Monolith to Microservices with Java and Node.
IBM Redbooks, Armonk (2016)
8. Doval, D., Mancoridis, S., Mitchell, B.S.: Automatic clustering of software systems
using a genetic algorithm. In: STEP, pp. 73–81. IEEE (1999)
9. Dragoni, N., et al.: Microservices: yesterday, today, and tomorrow. Present and
Ulterior Software Engineering, pp. 195–216. Springer, Cham (2017). https://doi.
org/10.1007/978-3-319-67425-4 12
10. Evans, E.: Domain Driven Design: Tackling Complexity in the Heart of Business
Software. Addison-Wesley, Boston (2004)
11. Faitelson, D., Tyszberowicz, S.: Improving design decomposition. Form. Asp. Com-
put. 22(1), 5:1–5:38 (2017)
12. Fowler, M.: MonolithFirst (2015). https://martinfowler.com/bliki/MonolithFirst.
html#footnote-typical-monolith. Accessed Mar 2018
13. Francesco, P.D., et al.: Research on architecting microservices: trends, focus, and
potential for industrial adoption. In: ICSA, pp. 21–30. IEEE (2017)
14. Hassan, M., Zhao, W., Yang, J.: Provisioning web services from resource con-
strained mobile devices. In: IEEE CLOUD, pp. 490–497 (2010)
15. Hassan, S., Bahsoon, R.: Microservices and their design trade-offs: a self-adaptive
roadmap. In: SCC, pp. 813–818. IEEE (2016)
Identifying Microservices Using Functional Decomposition 65