0% found this document useful (0 votes)
19 views

2018 ACM An Automatic Extraction Approach - Transition To MS Architecture From Monolithic Application

Uploaded by

Danelys
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

2018 ACM An Automatic Extraction Approach - Transition To MS Architecture From Monolithic Application

Uploaded by

Danelys
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

An Automatic Extraction Approach - Transition to

Microservices Architecture from Monolithic Application


Sinan Eski Feza Buzluca
Computer Engineering Department, Computer Engineering Department,
Istanbul Technical University, Istanbul, Istanbul Technical University, Istanbul,
Turkey, [email protected] Turkey, [email protected]

ABSTRACT
Microservice architecture has been introduced as a new 1 INTRODUCTION
alternative to the monolithic architecture. It has several benefits In recent years, applications that need to scale up to thousands
like scalability, reliability, increase in agility and productivity, or millions of users are very common due to many factors such
resilience to failure, ease of deployment and maintenance, and as the number of users with Internet access, the use of mobile
decrease in time to market. Therefore, software companies have application stores etc. Traditional enterprise systems are
showed a tendency to transform architecture of their legacy designed as monolithic applications, which are difficult to scale,
applications from monoliths to microservice architecture. In this understand and maintain. Microservice architecture is
transformation process, software development teams face the introduced to solve these problems.
challenge of migration of large applications to the new
Lewis and Fowler define the microservice architecture as an
architecture, where understanding the current application and
approach to develop a single system as a suite of small services,
reusing existing code base are important. In this paper, we
each running in its own process and communicating with
propose a new approach to transform existing applications into
lightweight mechanisms, often an HTTP resource API [1,2].
microservices using code repositories. We use evolutionary and
Microservice architecture is an intuitive concept, it advocates
static code coupling information, and the graph clustering
creating a system as a collection of autonomous services that
methodology, in order to automatically extract microservices interact with each other [1, 2]. Each microservice is designed to
from monoliths. In experimental analysis, we investigate two “do one thing and do it well”, known as the Unix philosophy [3].
software projects and our approach reach up to 89% of success Microservices are the next evolutionary design paradigm in
rate by comparing extracted microservices with the actual software not purely because of technical reasons but also
results. microservices enable companies to structure their system in the
same way they structure their teams, dividing responsibilities
CCS CONCEPTS among team members and building autonomous teams to act
• Computer systems organization → Cloud computing; • according to their needs. The microservice architecture is being
Software and its engineering → Software configuration adopted by many key technological players such as Netflix,
management and version control systems; • Software and its SoundCloud and Amazon [4, 5].
engineering → Software design techniques Correctly identifying software modules gains importance
with the increasing popularity of distributed systems and cloud
KEYWORDS computing, there has been a tendency to transform existing
Microservices, Graph Clustering, Software Architecture, monoliths into discrete and isolated services. Developers attempt
Microservice Transformation to manually identify modules in a software system to migrate
the underlying services into standard, autonomous and
ACM Reference format: distributed services. Distributing these services by transferring
them into cloud-based and service-oriented platforms properly
Permission to make digital or hard copies of all or part of this work for personal or can improve the performance, reliability and security of the
classroom use is granted without fee provided that copies are not made or programs. The common problem in these efforts is that
distributed for profit or commercial advantage and that copies bear this notice and
the full citation on the first page. Copyrights for components of this work owned
identifying components of monoliths that can be turned into
by others than ACM must be honored. Abstracting with credit is permitted. To cohesive services with well-defined boundaries and single
copy otherwise, or republish, to post on servers or to redistribute to lists, requires responsibility.
prior specific permission and/or a fee. Request permissions from
[email protected]. In this paper, we propose a method for decomposition of the
monolithic systems by identifying microservices automatically.
XP '18 Companion, May 21–25 2018, Porto, Portugal
© 2018 Association for Computing Machinery.
We obtain static and evolutionary coupling properties of
ACM ISBN 978-1-4503-6422-5/18/05…$15.00 software classes from existing code repositories and apply graph
https://doi.org/10.1145/3234152.3234195 clustering methods to identify microservices. To the best of our
XP '18 Companion, May 21–25 2018, Porto, Portugal S. Eski et al.

knowledge, this is the first research study that employs static monolithic application and show how this VM family turns into
and evolutionary coupling information together for automatic microservices by using image synthesis and analysis techniques.
extraction of microservices from monoliths. In this study, we In order to take benefits of microservices, [14] describes a
have two hypotheses that we have tested empirically: technique to identify and define microservices on a monolithic
enterprise system. They migrate a 750 KLOC banking system
 Extracting microservices from monoliths using into microservice architecture with mapping database tables to
combination of static and evolutionary coupling gives subsystems, then create a dependency graph between facade and
better results than just using static coupling, because business classes, pair them and group this pair by relation with
evolutionary coupling can identify logical coupling subsystems and identify microservice candidates. They migrate
that cannot be seen in static analysis. monolith application to microservices using as a case study.
 Extracting microservices from monoliths using Mazlami et al. use logical, semantic and developer coupling to
combination of static and evolutionary coupling gives extract microservices from existing systems [15]. They create
better results than just using evolutionary coupling. different graphs according to these couplings and cluster graphs
Since stable code parts are not changed so often and using their approaches which is an evaluated version of
some parts of code are lesser affected by change Minimum Spanning Tree algorithm, then they validate results
requests, we can see these relations in static analysis. with two quality metrics, defined by them, as team size
In our experimental analysis, we show that using both static reduction and average domain redundancy. They do not
and evolutionary coupling gives better results than just using compare results with a reference microservice model that is
static or evolutionary coupling. The remainder of this paper is provided by development teams or experts, and their results do
organized as follows: Related works are presented in the Section not include clustered module count and sizes. Also, their quality
2. The proposed method, system architecture and methodologies metrics give best results when each class is mapped as a
that are used in empirical analysis are presented in Section 3. microservice.
Section 4 shows the case studies and obtained results. Section 5
concludes the paper.
3 PROPOSED MICROSERVICE EXTRACTION
APPROACH
2 RELATED WORK
In this approach, we analyse static codes and software
Decomposing software systems has been an important branch in repositories to extract relations and changes in the software
the software engineering research discipline – extracting system. We represent the software system as a graph that shows
microservices from monoliths is the next evolutionary form of different relations and couplings between the classes. We apply
the original challenge of decomposing systems. The research for graph clustering technique on the graph to identify microservice
microservices starts from 2014 and increases following years, candidates. Model Representation:
and previous microservice studies are collected and classified
systematically in the survey articles [5, 6, 7, 8]. Decomposing  Graph: G<V, E> where V is the set of vertices and E is
software systems has been an important branch in the software the set of directed edges.
engineering. Extracting microservices from monoliths is the next  Vertices {vi} : Class or Interface
evolutionary form of the original challenge of decomposing  Edges{ei}: Static and/or evolutionary coupling
systems.  Static coupling: Inheritance, method call, aggregation,
Today some researchers have leant towards migration of creation, parameter, … etc
monoliths to microservice architecture published case studies  Evolutionary coupling: Co-changes where two
and empirical studies [4, 9]. Several approaches have been artefacts change frequently.
declared to transition into a microservice architecture [10, 11, 12,
 Shape: Same shape and colour indicates vertices in the
13, 14, 15]. One of these approaches is defined as a strangulation
same reference microservice.
method [10, 11]. In this method, microservice is written when a
 Cluster: Identified microservice candidates with our
change is needed and deciding which domain object is affected
proposed approach
by this change is conducted by domain experts. A sample work
on converting monoliths into microservices is done on Java
3.1 System Architecture of the Extraction
applications using Spring MVC [12], they propose a model-
centered process to analyze and visualize the current structure Methodology
and dependencies between the business layer and the data layer. The proposed system architecture of the extraction methodology
First, they identify and cluster Java Beans according to data they is given in Figure 1. The evolutionary Analysis module extract
manipulate and then form these groups according to persistence and save software change information using repositories. We
of shared types to find microservices. Kecskemeti et al. propose detect rename and move operation and protect historical
to [13], they introduce another methodology in their ENTICE information of renamed or moved class in the software
environment with creating a recipe based on a generic Virtual refactoring process. We extract evolutionary coupling by
Machine (VM) image, utilize this image using previous detecting changes between consecutive commits. The static
Analysis module extract static couplings on final revision of an
2
An Automatic Extraction Approach - Transition to Microservices
XP '18 Companion, May 21–25 2018, Porto, Portugal
Architecture from Monolithic Application

investigated project by parsing abstract syntax trees. Then we


create software relation graph which has static and evolutionary
couplings.

Figure 2: Clustering Dendogram.

3.3 MoJoSim Similarity Metric


In order to evaluate the quality of our approach we measure
Figure 1: System Architecture of the Extraction similarities between identified microservice candidates and
Methodology reference microservices (Authoritative Decomposition) that are
created by the developers of related projects. We use the widely
3.2 Fast Community Graph Clustering preferred MoJoSim(A, B) similarity metric to compare the results
produced by several module extraction methods and the expert
Algorithm
decomposition [17, 18, 21, 22].
The graph Clustering module clusters the graph and identifies Let A and B two partitions, mno(A, B) is the minimum
microservice candidates. We use Fast Community [16] graph number of move and join operations to transform partition A to
clustering algorithm since we obtained better results in the partition B where move operation moves a node from one
modularization of the OO systems than other graph-clustering module to another module and join operation merges two
algorithms in preliminary studies [17, 18]. The algorithm is modules into one module [23]. MoJo(A, B) and MoJoSim(A, B)
based on the idea of maximizing the modularity function, which are formulated as follows:
is defined as follows [19]:

where weii is the weighted fraction of internal edges which fall


Authoritativeness is defined as MoJoSim(M,MA), where M is
within a cluster (module) i, and wai is the weighted fraction of all
the set of the modules that is produced by the analysed method,
external edges that are attached to vertices in cluster i. If the
MA is the authoritative decomposition given by the experts, and
ends of the edges are randomly connected, the fraction of the
n is the number vertices in the dependency graph.
resulting edges that connect vertices within cluster i is computed
as wai2. A higher value of Qw represents a better community
division. However, attempting to find the best decomposition 4 CASE STUDIES AND EMPRICAL ANALYSIS
with the highest Qw value in a very large search space of all We analysed two Java projects: eQuality and Academics. We
possible partitions is infeasible. Among existing solutions, Fast added edges to the graph with following criteria: S used for
Community is an agglomerative hierarchical algorithm based on “static coupling”, E for “evolutionary coupling”, C and R for
greedy optimization as it is basically explained in the following threshold values. As a formula, E (C OR R) represents
steps [18]: evolutionary coupling showing that two classes change together
at least C times, or their change ratio is greater than R.
1- Initially, assign each vertex to a different cluster.
2- Join two clusters that result greatest increase (or
smallest decrease) in Qw (max. ∆Qw). 4.1 eQuality
3- Repeat step 2 until only one cluster remains. The first project, eQuality [24] is a software quality
4- Select cut level in the resulting dendrogram by measurement and visualization tool. We investigate 1729
looking for maximal Qw value. revisions to extract evolutionary coupling. We plot distribution
A sample dendrogram is shown in Figure 2. In [20], it is of change count and change rates and select threshold according
shown that with the incremental calculation of Qw, the to these distributions. We use median and 3rd quarter values
asymptotic time complexity of the algorithm is O(|E|dlog|V|) that are 5,10 and 0.6, 0.8 respectively. For the AND operation we
where d is the depth of the dendrogram. For OO graphs, which use 1st quarter value for ratio which is 0.3. Similarity results are
are sparse and have a hierarchical structure, the number of edges shown in Table 1, visual representation of microservice
is close to the number of vertices (|E|~|V|) and d~log|V|, so that the candidates for S+E(5 OR 0.8) in Figure 3.
running time complexity is O(|V|log2|V|).

3
XP '18 Companion, May 21–25 2018, Porto, Portugal S. Eski et al.

Figure 3: eQuality microservice candidates


Figure 4: GRAPH/CLUSTER sub-clustering results
Some microservice candidates have large number of class and
LOC values. After we compared these candidates to our The same situation exists in the VERSION module. Our
reference model, we saw that these candidates contain different approach extracted the version module to the three
microservices. Then, we applied clustering operation for these microservices as core model, compare and analysis; but the
big candidates to extract microservices. GRAPH/CLUSTER’s sub- developers decomposed this service into two microservices. The
clustered graph is given in Figure 4 and the results have developers mentioned that extra services could be developed as
similarity between microservice candidates and authoritative different microservices according to single responsibility
references. We sub-clustered EXTRACTORS and showed that patterns but decided to use these code blocks in same
core-model, dummy-extractor, cpp-extractor and java-extractor microservice in terms of maintenance. Similarity results are
microservices are decomposed as microservice candidates. Some given in Table 2 for each sub-clustering.
classes of core-model have been misplaced to cpp-extractor
microservice candidates because of their strong static relations.
Table 2: MoJoSim similarity results of sub-clustering

Table 1: MoJoSim similarity results for eQuality Module MoJoSim(A, B) #Microservice


GRAPH/CLUSTER 89.33 3
Coupling MoJoSim(A,B) #Microservice EXTRACTORS 78.26 4
S 76.99 13 GRAPH-MODEL/IO 91.3 3
E (5 OR 0.8) 48.52 120 VERSION 71.43 3
S+E(5 OR 0.6) 88.1 6 IO/GATEWAY 56.9 8
S+E(5 OR 0.8) 88.32 8 IO/GATEWAY candidate includes user interface (UI)
S+E(10 OR 0.6) 82.91 8 operations, gateway operations that include communication
S+E(10 OR 0.8) 82.05 8 between UI, backend and in-memory management service. UI
S+E(3 AND 0.3) 80.52 10 and gateway operations have strong relations, our approach has
S+E(5 AND 0.3) 81.38 10 low success rate for extracting microservices from this cluster.
GRAPH-MODEL/IO candidate has 2 microservices in the
reference model: graph-io-service and graph-model-service. Our 4.2 Academics
method split graph-model classes to two microservices. After we Academics is a web crawling project. We investigate 376
examined these candidates with the developers, we saw that revisions. We plot distribution change count and change rates
these group of classes had their individual boundaries and they and select threshold according to these distributions. We use
were cohesive in each group. First group includes classes that are median and 3rd quarter values that are 2,3 and 0.6, 0.8
related with graph representation, and the second group includes respectively. For the AND operation we use 1st quarter values
graph transformation operations. for ratio which is 0.3. Similarity results are given in Table 3. The
graph clusters for S+E(3 OR 0.8) are given in Figure 5.

4
An Automatic Extraction Approach - Transition to Microservices
XP '18 Companion, May 21–25 2018, Porto, Portugal
Architecture from Monolithic Application

Table 3: MoJoSim similarity results for Academics results may not be generalizable to all open-source projects or
commercial projects. More results are needed to be gathered
Coupling MoJoSim(A, B) #Microservice from projects with different characteristics.

S 71.81 10
E (2 OR 0.6) 61.22 19
5 CONCLUSION
S+E(2 OR 0.6) 74.03 3 In this paper, we propose a graph based microservice clustering
S+E(2 OR 0.8) 72.08 3 approach using static and evolutionary coupling between
S+E(3 OR 0.6) 77.78 4 software classes.
S+E(3 OR 0.8) 78.55 6 In empirical analysis, we show that using both static and
S+E(2 AND 0.3) 70.55 4 evolutionary coupling give better results than just using static
One of the differences between the reference model and coupling (Hypothesis 1) or evolutionary coupling (Hypothesis 2)
microservice candidates is that our model split academician for both eQuality and Academics projects. We displayed that
collection microservices to three microservices. Our method some extracted services were too big and violated single
combines some microservices into one microservice candidate. responsibility principle, so we sub-clustered these services in
After we investigate these candidates, we saw that combined order to decompose them into microservices. Extracted
microservices are related to each other for example browser- microservice candidates were compared with authoritative
crawler and faculty-crawler are combined since faculty-crawler reference microservice models that were prepared by developers.
has a strong relation with browser-crawler microservices. We measured similarity between candidates and actual services
In this part we tested our Hypotheses. In the experiment of and showed that the success rate of our approach reached to
eQuality project, we show that MoJoSim(A, B) reached up to 89%. Also, we examined the candidate microservices with
88.32 when using both coupling types together; on the other developers and analysed differences between the results of our
hand, when we used these methods separately, we got similarity approach and developers’ reference model. We saw that in some
success rates as 76.99 and 48.52 for static and evolutionary cases, our approach decomposed services into more
coupling respectively. In the experiment of Academics projects, microservices compared to developers’ model. Developers agreed
we saw similar results for MoJoSim(A, B) 78.55, 71.81 and 62.22 that more fine-grained microservices could be also developed
corresponding for both coupling, only static and only based on single responsibility principle. However, they preferred
evolutionary coupling respectively. to collect these fine-grained services in one microservices for
maintenance purposes.
As a future study, we are planning to improve our approach
by giving weights to graph edges to increase accuracy of
extraction results and automatically determining thresholds for
sub-clustering services. We are also planning to experiment with
more industrial and open-source projects and compare result
using different clustering algorithms.

REFERENCES
1 S. Newman, Building Microservices, O’Reilly, 2015.
2 M. Fowler, J. Lewis, Microservices a definition of this new architectural term,
Retrieved 2018, January, from
http://martinfowler.com/articles/microservices.html.
3 Basics of the Unix Philosophy - Chapter1.Philosophy, Retrieved 2018, March
from: https://homepage.cs.uri.edu/~thenry/resources/unix_art/ch01s06.html
4 C. Y. Fan and S. P. Ma, Migrating Monolithic Mobile Application to
Microservice Architecture: An Experiment Report, 2017 IEEE International
Conference on AI & Mobile Services (AIMS), Honolulu, HI, 2017, pp. 109-112.
5 N. Alshuqayran, N. Ali, R. Evans, A systematic Mapping Study in Microservice
Architecture, IEEE 9th International Conference on Service-Oriented
Figure 5: Academics microservice candidates Computing and Applications, 2016, DOI: 10.1109/SOCA.2016.15
6 Vural H., Koyuncu M., Guney S. (2017) A Systematic Literature Review on
Microservices, In: Gervasi O. et al. (eds) Computational Science and Its
4.3 Threats to validity Applications – ICCSA 2017. ICCSA 2017. Lecture Notes in Computer Science,
vol 10409. Springer, Cham
A threat to internal validity is that the developers extract 7 C. Pahl, P. Jamshidi, Microservices: A Systematic Mapping Study, Proceedings
authoritative reference microservices from projects manually. of the 6th International Conference on Cloud Computing and Services
Science, pp. 137-146, 2016, DOI: 10.5220/0005785501370146.
Although, to overcome misclassification, developers cross-check 8 D. Taibi, V. Lenarduzzi, C. Pahl., Architectural Patterns for Microservices: a
reference microservices, we cannot exclude that manual analysis Systematic Mapping Study, 8th International Conference on Cloud Computing
could have miss assigning some classes to microservices. Threats and Services Science, XCLOSER 2018
9 J. P. Gouigoux and D. Tamzalit, From Monolith to Microservices: Lessons
to external validity concern the generalization of the results. Learned on an Industrial Migration to a Web Oriented Architecture, 2017 IEEE
Although we select two commercial projects for this study, the International Conference on Software Architecture Workshops (ICSAW),
Gothenburg, 2017, pp. 62-65

5
XP '18 Companion, May 21–25 2018, Porto, Portugal S. Eski et al.

10 Chris Richardson, Refactoring a Monolith into Microservices, 2016, Retrieved


2018, January, from: https://www.nginx.com/blog/refactoring-a-monolith-
into-microservices/
11 Kyle Brown, 2017, Apply the Strangler Application pattern to microservices
application, Retrieved 2018, February, from:
https://www.ibm.com/developerworks/cloud/library/cl-strangler-application-
pattern-microservices-apps-trs/index.html
12 D. Escobar et al., Towards the understanding and evolution of monolithic
applica-tions as microservices, XLII Latin American Computing Conference
(CLEI), Val-paraíso, 2016, DOI: 10.1109/CLEI.2016.7833410
13 Kecskemeti, G., Marosi, A.C., Kertesz, A. "The ENTICE approach to
decompose monolithic services into microservices," 2016 International
Conference on High Performance Computing & Simulation (HPCS),
Innsbruck, 2016, pp. 591-596. DOI: 10.1109/HPCSim.2016.7568389
14. Alessandra Levcovitz; Ricardo Terra; Marco Tulio Valente. Towards a
Technique for Extracting Microservices from Monolithic Enterprise Systems.
3rd Brazilian Work-shop on XSoftware Visualization, Evolution and
Maintenance (VEM), p. 97-104, 2015
15 G. Mazlami, J. Cito and P. Leitner, "Extraction of Microservices from
Monolithic Software Architectures", IEEE International Conference on Web
Services (ICWS), Honolulu, HI, 2017
16 M. E. J. Newman and M. Girvan, "Finding and evaluating community structure
in networks", Phys. Rev. E 69, 2004, DOI: 10.1103/PhysRevE.69.026113
17 Erdemir, U., Tekin, U. ve Buzluca, F. (2011). Object Oriented Software
Clustering Based on Community Structure, 18th Asia Pacific Software
Engineering Conference (APSEC X2011), Ho Chi Minh City, Vietnam: IEEE
Computer Society, December 5-8.
18 U. Erdemir, F. Buzluca,"A Learning-Based Module Extraction Method for
Object-Oriented Systems, J. Syst. Software, 97 (2014), pp. 156-177
19 Newman, M. E. (2004). Fast algorithm for detecting community structure in
networks. Physical Review E, 69(6), 066133
20 A. Clauset, M. E. J. Newman, and C. Moore, "Finding community structure in
very large networks", Physical Rev. E 70, 066111, 2004
21 Wu, J., Hassan, A. E. and Holt, R. C. (2005). Comparison of clustering
algorithms in the context of software evolution, Proceedings of the 21st IEEE
International Conference on Software Maintenance, (pp. 525–535) Budapest,
Hungary
22 Bittencourt, R. A. and Guerrero, D. D. S. (2009). Comparison of graph
clustering algorithms for recovering software architecture module views, 13th
IEE European Conference on Software Maintenance and Reengineering, (pp.
251–254)., Germany, March 24-27.
23 Tzerpos, V. and Holt, R. C. (1999). MoJo: A distance metric for software
clusterings, Proceedings of the Sixth IEEE Working Conference on Reverse
Engineering, (pp. 187–193). Atlanta, Georgia, USA : IEEE Computer Society,
October 6-8
24 Erdemir, U., Tekin, U., Buzluca, F.. "E-Quality: A Graph Based Object Oriented
Software Quality Visualization Tool". In Proceedings of the 6th IEEE
International Workshop Xon Visualizing Software for Understanding and
Analysis, pp..6–13, Virginia, USA. 2011.

You might also like