Monolith to Microservices: Representing Application Software through Heterogeneous Graph Neural Network

Alex Mathai, Sambaran Bandyopadhyay, Utkarsh Desai, Srikanth TamilselvamIJCAI 2022 · DOI

TL;DR

This paper tackles the challenging task of migrating monolithic software to microservices by proposing a novel Heterogeneous Graph Neural Network (CHGNN). CHGNN effectively represents both code and data artifacts as a unified graph, enabling constraint-based clustering to identify cohesive microservice candidates. This approach leads to more evenly distributed and functionally aligned microservice partitions compared to existing methods.

What Problem Does This Paper Address?

The migration of monolithic software applications to microservices is a complex and labor-intensive process. Monoliths, while simple to develop initially, become difficult to manage, scale, and update as they age. Microservices offer benefits like independent deployment and scalability, but breaking down a monolith requires deep analysis of its functional components and their relationships. Existing approaches often struggle with representing the full spectrum of software artifacts (code, databases, files) and their intricate relationships, leading to suboptimal decompositions. Furthermore, real-world migrations often involve expert-defined constraints (e.g., specific components that must belong together), which current methods don't adequately incorporate. This paper aims to bridge this gap by providing a more comprehensive and constraint-aware method for software decomposition.

Methods

The core of this paper is the Community-aware Heterogeneous Graph Neural Network (CHGNN). Here's a breakdown of their approach:

  • Heterogeneous Graph Representation: They first transform the monolithic application into a heterogeneous graph. This graph includes different types of nodes: "Program" nodes (representing classes or functions) and "Resource" nodes (representing database tables, files, etc.). Edges represent various relationships like function calls, inheritance, and data access (CRUD operations).
  • Node and Edge Attributes: Both program and resource nodes are enriched with attributes derived from their functionality, entry points, and inheritance relationships. Edge attributes capture the type of resource access.
  • Message Passing GNN: CHGNN employs a message-passing mechanism to learn embeddings for both nodes and edges. This process allows information to propagate through the graph, capturing structural and attribute information. They use multiple layers for encoding (compressing features) and decoding (decompressing features).
  • Constraint-Based Clustering: A key innovation is the integration of clustering directly into the GNN framework. They introduce a loss function that not only encourages reconstruction of node/edge attributes and links but also incorporates two types of clustering objectives:
  • Unifying Node Clustering: A k-means++ objective is used to group similar nodes into clusters, representing potential microservices.
  • Seed Constraints: The model explicitly handles expert-provided "seed sets" – groups of artifacts that must belong to the same microservice. This is enforced through hard constraints in the clustering assignment and a soft constraint that maximizes the distance between seed set centers in different clusters.

Datasets

The authors evaluated their approach on four publicly available monolith applications:

  • Daytrader (Java)
  • PlantsbyWebsphere (PBW) (Java)
  • Acme-Air (Java)
  • GenApp (Cobol)

They note that they did not include "DietApp" as its public repository lacked the necessary code for interfacing between programs and tables, making it unsuitable for their graph construction.

Key Insights and Ideas

  • Heterogeneity Matters: Representing both code (programs) and data (resources) in a unified graph, along with their diverse relationships, is crucial for accurate microservice decomposition. Ignoring data resources or treating all relationships uniformly leads to less effective results.
  • Expert Constraints are Valuable: Incorporating SME-provided seed sets significantly improves the quality and relevance of the generated microservice partitions, ensuring that critical functional units are kept together.
  • Balanced Microservices: CHGNN tends to produce more evenly sized microservice clusters, avoiding the issue of having a few very large services and many tiny ones, which is often undesirable in practice. This leads to better resource utilization and manageability.
  • Joint Optimization: Simultaneously learning node/edge embeddings and performing clustering within a single GNN framework allows for a more holistic optimization, where embeddings are pulled towards cluster centers while also maintaining structural integrity.

Key Results

  • Quantitative Performance: In Table 1, CHGNN consistently achieved higher "Metricsum" scores across all tested monoliths compared to the baseline COGCN++. The average Metricsum for CHGNN was 2.000, while COGCN++ scored 1.336. Heterogeneous graph formulations (CHGNN, CHGNN-EL, HetGCNConv) generally outperformed the homogeneous COGCN++.
  • Qualitative Analysis (PBW Example): Figure 2 demonstrates that CHGNN successfully identified five functional clusters (Customer, Order, Inventory, BackOrder, Supplier) with programs and resources exhibiting close dependencies. In contrast, COGCN++ produced more skewed cluster sizes and incorrectly associated some artifacts.
  • SME Validation: An SME validated CHGNN's results, noting that the clusters were more evenly distributed and that customer-related artifacts were correctly grouped.

Limitations and Future Work

  • Limitations:
    • The paper acknowledges that COGCN++ (a baseline) does not ensure mutual exclusivity of seed sets, which they addressed by adding a seed constraint loss.
  • The authors mention that their approach, like many graph-based methods, can be sensitive to the quality of the input graph and the chosen hyperparameters.
  • Future Work: The authors propose extending their work to decompose applications at a more granular level, moving from programs to functions and from tables to columns. They also suggest further exploring the impact of different graph construction strategies and GNN architectures.

Summary updated

BibTeX
@inproceedings{mathai2022monolith,
  author = {Alex Mathai and Sambaran Bandyopadhyay and Utkarsh Desai and Srikanth Tamilselvam},
  title = {{Monolith to Microservices: Representing Application Software through Heterogeneous Graph Neural Network}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.24963/ijcai.2022/542},
}
Figure