On the Migration from a Monolithic System to aMicroservices Architecture:
A Study of Automated Decomposition Approaches

Khaled Sellami
19 April 2024

Faculty of Science and Engineering
Department of Computer Science and Software Engineering

The Monolithic Architecture (1/2)• Definition: A Monolith is a single unit of deployment.

Monolith
Monolith

Module 2

DBDBSingle Process Monolith

Modular Monolith• Simple development process2

Module 1

Module 3-

Lack of scalability-High coupling

The Monolithic Architecture (2/2)
Overview of SoundCloud’s first architecture (2007) [1]:Overview of SoundCloud’s last monolithic architecture (2012) [1]:[1] Sean Treadway: https://developers.soundcloud.com/blog/evolution-of-soundclouds-architecture
3

The Microservices Architecture (1/2)•Independent deployability•

Business Domain Driven•

Small microservices•

Modularity• Horizontal Scalability• Robustness• Technology diversity• Clear isolation
4• Convient for cloud and devops-

Implementation complexity-

Deployment overhead-

Adapting to new workflows

The Microservices Architecture (2/2)

Overview of SoundCloud’s microservices’architecture (2024) [2]:[2] Stephen Sun: https://www.fullstackexpress.io/p/evolution-soundcloud-architecture-final
5

Migrating from the Monolith to Microservices: what is it?

Monolith
6Microservices

Migrating from the Monolith to Microservices: Why?

Why migrate from a monolith to microservices• Scalability• Development productivity• Modernizing legacy application

7

Migrating from the Monolith to Microservices: How?

A. Initiation

8

B. Planning

C. Execution

D.
MonitoringMigrating from the Monolith to Microservices: Challenges

A. Initiation

9•

Expensive•

Lengthy•Lack of experience

B. Planning

C. Execution

D.
MonitoringMigrating from the Monolith to Microservices: Who?

10

Decomposition approaches: Definition
A decomposition approach is a solution that partitions the components of amonolithic application (OOP classes, method, database tables, etc) into a set of
potential microservices.
A. Initiation

1- Analysis

11

B. Planning

C. Execution

D.
Monitoring

2- decomposition

Decomposition approaches: Advantages- Improve and evolve instead of refactoring- Lower migration costs- Ability to experiment before committing- A starting point for traditional migration processes- Unique perspective on the representation of the monolith

12Decomposition approaches: Analysis (1/3)

Monolithic application

13

ClinicService

VetPetTypeOwner

Pet

Visit

Specialty

VisitRepo

1- Analysis

Intermediate representation

Decomposition approaches: Analysis (2/3)
Execution traces + dynamic analysis

•
••
•
•
14

Mono2micro [3]FoSCI [4]Process Mining Decomp [5]
CoGCN [6] + Deeply [18]toMicroservices [17]Source code + static analysis•••

SArF [8]Topic Modeling decomp [9]MVC decomp [10]Database + source
code• CARGO [16]• CHGNN [7]• DataCentric [15]

Decomposition approaches: Analysis (3/3)
Feature extraction•15

Code2Vec decomposition [11]Design artifacts• Service Cutter [14]• DataFlow Decomp [12]• AKF decomp [19]Commit history• MEM [13]

Decomposition approaches: Decomposition (1/2)
Monolithic application
ClinicService

Vet service

Visit

Vet

VisitRepo

Specialty

Vet

PetType

Owner

Pet

Visit

Specialty

Visit service

VisitRepo

Owner service
2- decomposition

PetType

Owner
Pet

Gateway service
ClinicService

Decomposition16

Decomposition approaches: Decomposition (2/2)
Clustering••
•••
•
••
•

MEM [13]
Mono2micro [3]Service Cutter [14]Topic Modeling [9]SArF [8]MVC decomp [10]Code2Vec decomp [11]DataFlow decomp [12]FoSCI [4]GeneticAlgorithms

Graph NeuralNetworks•CHGNN [7]•CO-GCN [6] + Deeply [18]•FoSCI [4]HierDecomp: Introduction
A Hierarchical DBSCAN Method for Extracting Microservices
from Monolithic Applications
The International Conference on Evaluation and Assessment in Software Engineering 2022 (EASE2022)

Main contributions:•A hierarchical decomposition suggestion for result explainability and user choice flexibility.

•Number of target microservices is inferred.

•Introduce a new evaluation approach for microservices decomposition.

18

HierDecomp: Analysis
HierDecomp
Source code analysis

Decomposition
Source code

Structural analysis
microservice
extraction
Semantic analysis

19

HierDecomp: Semantic Analysis
HierDecomp
Source code analysis
Structural analysis
Decomposition

Semantic analysis
Source code
CamelCase
splitting• CartItem• removeItemById• isInStock20

•
•
•
•
•
•
•
•
•

cart
item
removeitem
byidisinstock

Stopwordfiltering

•••••
•

cart
item
removeitemidstock

Stemming•
•••
••

cart
item
remov
item
idstock

TF-IDF
vectorization

microservice
extraction

HierDecomp: Structural Analysis
HierDecomp
Source code analysis
Structural analysis
Decomposition
Source code
microservice
extraction

Abstract
Syntax Trees

Call graphs

Semantic analysis
21

HierDecomp: epsilon-DBSCAN (1/2)
HierDecomp
Source codeanalysis

microservice extraction

Decomposition
Source code

Structuralanalysis

Semanticanalysis

22

HierDecomp : epsilon-DBSCAN (1/2)
HierDecomp
Source codeanalysis

Source code

microservice extraction

ε-DBSCAN

Structuralanalysis
NxNsimilarity
matrixSemanticanalysis

23

DBSCAN

Increment εDecomposition

HyDec: introduction
Combining Static and Dynamic Analysis to Decompose
Monolithic Application into Microservices
The 20th International Conference on Service-Oriented Computing 2022 (ICSOC2022)

Main contributions:•A general approach to combine multiple analysis sources in order to generate hierarchical decompositions.

•Multiple combination approaches.

•A decomposition approach that improves the coverage while maintaining a performance similar to state-ofthe-art approaches.

24HyDec: Overview
Structural analysis
Source code+
Semantic analysis+
Execution logs

Dynamic analysis

25?

Microservices
recommendation

HyDec: Dynamic analysis
Dynamixanalysis result

Execution traces

Execution logs
Duplicate removal
MxM call matrix
M=6 in example

26

HyDec: Static similarity
NxN interaction
Matrix M

Call similarity

NxN structuralsimilarity
Mmatrix

Weightedaverage

NxV TFIDF
Matrix M

27

Cosine similarity

NxN semanticsimilarity
Mmatrix+NxN staticsimilarity
matrixHyDec: Sequential epsilon-DBSCAN
DynamicManalysisStaticM
analysis

Clustering (ε2)...

Clustering (εn)

Representation boundary

Clustering (ε)

Clustering (ε)

Clustering (ε2)...

Clustering (εm)
28HyDec: Alternating epsilon-DBSCAN
StaticM
analysis

Clustering (ε)

Clustering (ε)

Clustering (ε2)...

Clustering (εn)

29Representation boundary

DynamicManalysis

Clustering (ε2)...

Clustering (εm)

MSExtractor: Introduction
Improving microservices extraction using evolutionary search
The Journal of Information and Software Technology Volume 151

Main contributions:•Formulating the microservices decomposition task as a search problem with an evolutionary algorithm.

•Using a multi-objective evolutionary algorithm in order to encapsulate the different aspects within adecomposition.

•Differentiating between interface and inner classes within a decomposition.

30

MSExtractor: Clustering vs Optimization
Microservice 1

Microservice 2

Microservice 3

Microservice 4

Microservice 5

A potential decomposition

Viable Decompositions

Search Space
31

MSExtractor: Overview

32

MSExtractor: Evolutionary algorithms
Evolutionary
Algorithms
Solution
representation

Mutation
operator

Initial population

Crossoveroperator

Fitness function
33

MSExtractor: WorkflowPopulation

Initialize
Population

Measure fitness

StopCriteria
metNo

Mutation

34

CrossoverSelect Parents

Yes

Decompositions

MSExtractor: Solution representation
label-based integer encoding:
M4

M2

M3

M3

M3

M1

M2

M1

ClinicService

Vet

PetType

Owner

Pet

Visit

Specialty

VisitRepo

4

Initial population: random sampling

35233

3121

MSExtractor: MOEA
Multi-Objective Evolutionary
Algorithm (MOEA)

Cohesion

Coupling

Granularity

Microservice 1

Microservice 1
Microservice 1
Class 1

Microservice 3

Class 2

Microservice 2
Microservice 2

36

MSExtractor: Operators
Crossover operator

Mutation operator

37

RLDec: Introduction
Extracting Microservices from Monolithic Systems using Deep
Reinforcement Learning
In Review for The Empirical Software Engineering

Main contributions:•Formulate the microservices decomposition problem as a reinforcement learning task.

•Improving the evaluation process by introducing novel metrics that can encapsulate multiple aspects
and that can compare with existing decompositions.

38

RLDec: Overview

39

RLDec: The sequential approach
t
St+1=

1

1

3

177

Rt =modularity(St+1)

St =

1

1

3

377

label-based integer encoding

40

At=1Feature
MatrixRLDec: The combined sequential approach

Rt= (SMQ(St+1)+
CMQ(St+1))/2

St =11337

At=17label-based integer encoding
SemanticFeature
Matrix41

StructuralFeature
MatrixRLDec: RQ2
How does our approach perform when compared with state-of-the-art decomposition baselines?

42

RLDec: RQ3 (1/2)
Is our approach able to recapture the components of microservices that were created by human experts?

Original microservices

Decomposition

Vet Service

Microservice 1

Vet

VetResource
Vet

VetRepository

Specialty

Pet Service

Visit ServicePetVisitPetDetails

VisitRepository

Config Server
ConfigServerApplication

VetResource

Compare

VetRepository

Microservice 2

Microservice 3

Pet

Visit

PetDetails

VisitRepository

Outliers
ConfigServerApplication

Specialty

43

RLDec: RQ3 (2/2)
Is our approach able to recapture the components of microservices that were created by human experts?

44

Representation learning: Motivation

Decomposition step45

Representation learning: Visualization

46

Representation learning: alternatives
word (set of characters) (ex:example)

47

Word Embedding model(ex: word2vec)

Vector representation (a numericvector) (example: a 300 dim vector)Representation learning: code embeddings

Code snippet (list of ASTpaths)

Code snippet represented as(text sequence (ex:docstring) + code sequence(method core))48

Code2vec

Vector representation (a numericvector) (example: a 300 dim vector)

CodeBERT

List of contextual vector
representation for each token in theinput (example: a matrix of shape50x300) and an aggregation vectorRepresentation learning: Large Language Models

49

Representation learning: Data Collection

50-Curated list of microservices applications in various programming languages used in research-A list of “special” applications that can be considered due to factors such as having a monolithicversion, the scale of the application and the structure of the repository-Keyword query: [regex=“micro( |-)?services?( |-)(architecture|system|application)”]-Collected 154 Java microservices applications and 91 C# microservices applications

Representation learning: Evaluation (1/2)
Evaluating the distribution of embeddings in the context Monolith to Microservices:
1.
2.
3.
4.

Generate the embeddings for each class or method in an application
Measure the similarity between each couple of classes/methods (for example cosine similarity)
Measure the binary cross entropy loss based on the actual decomposition.
Evaluate the models based on the mean score across all applications.

Model Name
Mean score

51

SFR-EmbeddingMistral
0.704

deepseekcoder-6.7Binstruct
0.736

OpenAI

Code2Vec
0.757

0.816

CodeBERT
0.873

semanticanalysis
0.964

structuralanalysis
19.700Representation learning: Evaluation (2/2)
Evaluating the distance between the generated decomposition and the actual decomposition:
1.
2.
3.
4.

Generate the embeddings for each class or method in an application
Generate a decomposition for each algorithm (k-means, hierarchical clustering, dbscan, etc)
Measure the MSFB score defined in the RLDec approach
Evaluate the models based on the mean score across all applications and algorithms.

Model Name
MSFB

52

SFR-EmbeddingMistral
0.300

deepseekcoder-6.7Binstruct
0.290

OpenAI

CodeBERT
0.283

0.250

Code2Vec
0.247

semanticanalysis
0.187

structuralanalysis
0.182

The decomposition platform: Current challenges- Increasing number of decomposition approaches- Difficulty of reproducing existing approaches- Varied number of evaluation metrics and their implementations- Multiple benchmark monolithic applications- Lack of visualization tools for decompositions

53

The decomposition platform: Objective
Objective: Share a standardized platform for applying and evaluating decomposition approaches andvisualizing decompositions

54

The decomposition platform: Architecture

55

Conclusion

56

References[1] Sean Treadway: https://developers.soundcloud.com/blog/evolution-of-soundclouds-architecture[2] Stephen Sun: https://www.fullstackexpress.io/p/evolution-soundcloud-architecture-final[3] Anup K. Kalia, Jin Xiao, Rahul Krishna, Saurabh Sinha, Maja Vukovic, and Debasish Banerjee. Mono2micro: A practical and effective tool for decomposing monolithic java applications to microservices. pages 1214–1224. Association for
Computing Machinery, Inc, 8 2021. ISBN 9781450385626. doi: 10.1145/3468264.3473915. URL https://dl.acm.org/doi/10.1145/3468264.3473915.
[4] Wuxia Jin, Ting Liu, Yuanfang Cai, Rick Kazman, Ran Mo, and Qinghua Zheng. Service candidate identification from monolithic systems based on execution traces. IEEE Transactions on Software Engineering, 47:987–1007, 5 2021. ISSN
19393520. doi: 10.1109/TSE.2019.2910531. URL https://ieeexplore.ieee.org/document/8686152.
[5] Davide Taibi and Kari Systä. From monolithic systems to microservices: A decomposition framework based on process mining. pages 153–164. SciTePress, 2019. ISBN 9789897583650. doi: 10.5220/0007755901530164. URL
https://www.scitepress.org/Link.aspx?doi=10.5220/0007755901530164.
[6] Utkarsh Desai, Sambaran Bandyopadhyay, and Srikanth Tamilselvam. Graph neural network to dilute outliers for refactoring monolith application. In AAAI Conference on Artificial Intelligence, 2 2021. URL http://arxiv.org/abs/2102.03827.
[7] Alex Mathai, Sambaran Bandyopadhyay, Utkarsh Desai, and Srikanth Tamilselvam. Monolith to microservices: Representing application software through heterogeneous graph neural network. 2022. URL
https://arxiv.org/abs/2112.01317https://www.ijcai.org/proceedings/2022/542.
[8] Manabu Kamimura, Keisuke Yano, Tomomi Hatano, and Akihiko Matsuo. Extracting candidates of microservices from monolithic application code. volume 2018-December, pages 571–580. IEEE Computer Society, 7 2018. ISBN9781728119700. doi: 10.1109/APSEC.2018.00072.
[9] Miguel Brito, Jácome Cunha, and João Saraiva. Identification of microservices from monolithic applications through topic modelling. 2021. doi: 10.1145/3412841.3442016.
[10] Luís Nunes, Nuno Santos, and António Rito Silva. From a monolith to a microservices architecture: An approach based on transactional contexts. volume 11681 LNCS, pages 37–52. Springer Verlag, 2019. ISBN 9783030299828. doi:
10.1007/978-3-030-29983-5_3.
[11] Omar Al-Debagy and Péter Martinek. A microservice decomposition method through using distributed representation of source code. Scalable Computing, 22:39–52, 2021. ISSN 18951767. doi: 10.12694:/scpe.v22i1.1836. URL
https://www.scpe.org/index.php/scpe/article/view/1836.
[12] Shanshan Li, He Zhang, Zijia Jia, Zheng Li, Cheng Zhang, Jiaqi Li, Qiuya Gao, Jidong Ge, and Zhihao Shan. A dataflow-driven approach to identifying microservices from monolithic applications. Journal of Systems and Software, 157:110380,
2019. ISSN 0164-1212. doi: https://doi.org/10.1016/j.jss.2019.07.008. URL https://www.sciencedirect.com/science/article/pii/S0164121219301475.
[13] Genc Mazlami, Jurgen Cito, and Philipp Leitner. Extraction of microservices from monolithic software architectures. pages 524–531. Institute of Electrical and Electronics Engineers Inc., 9 2017. ISBN 9781538607527. doi:
10.1109/ICWS.2017.61. URL https://ieeexplore.ieee.org/document/8029803.
[14] Michael Gysel, Lukas Kölbener, Wolfgang Giersche, and Olaf Zimmermann. Service cutter: A systematic approach to service decomposition. volume 9846 LNCS, 2016. doi: 10.1007/978-3-319-44482-6_12.
[15] Yamina Romani, Okba Tibermacine, and Chouki Tibermacine. 2022. Towards Migrating Legacy Software Systems to Microservice-based Architectures: a Data-Centric Process for Microservice Identification. In 2022 IEEE 19th International
Conference on Software Architecture Companion (ICSA-C). 15–19.
[16] Vikram Nitin, Shubhi Asthana, Baishakhi Ray, and Rahul Krishna. 2023. CARGO: AI-Guided Dependency Analysis for Migrating Monolithic Applications to Microservices Architecture. In Proceedings of the 37th IEEE/ACM International
Conference on Automated Software Engineering. Article 20, 12 pages.
[17] Wesley K. G. Assunção, Thelma Elita Colanzi, Luiz Carvalho, Juliana Alves Pereira, Alessandro Garcia, Maria Julia de Lima, and Carlos Lucena. 2021. A Multi-Criteria Strategy for Redesigning Legacy Features as Microservices: An Industrial Case
Study. In 2021 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER). 377–387.
[18] Rahul Yedida, Rahul Krishna, Anup Kalia, Tim Menzies, Jin Xiao, Maja Vukovic, Partitioning cloud-based microservices (via deep learning), 2021, arXiv preprint arXiv:2109.14569.
[19] Zhiding Li, Chenqi Shang, Jianjie Wu, Yuan Li, Microservice extraction based on knowledge graph from monolithic applications, Information and Software Technology, Volume 150, 2022, 106992, ISSN 0950-5849,
https://doi.org/10.1016/j.infsof.2022.106992.