Introduction
Refactoring monolithic software into microservices is a manual, error-prone process that often stumbles over "god classes"—complex components with too many responsibilities. This paper introduces CO-GCN, an unsupervised Graph Neural Network that represents software as an attributed graph and jointly learns to group classes into services while identifying and "diluting" the influence of these messy outlier classes.
The Challenge of Decomposition
As enterprises move to the cloud, they face the daunting task of "decomposing the monolith." A monolithic application—where all functions live in one deployable unit—is hard to scale and update. The goal is to break it into microservices: independent modules that handle specific business functions.
However, existing automated tools for this task have significant gaps. Many only look at the "structure" (which class calls which) and ignore the "semantics" (what the class actually does). Furthermore, almost every monolith contains outliers: classes that are either "structural outliers" (connected to almost everything) or "attribute outliers" (behaving differently than their neighbors). Standard clustering algorithms get confused by these outliers, leading to poor service boundaries.
Methodology: The CO-GCN Approach
The authors propose CO-GCN (Clustering and Outlier aware Graph Convolution Network), which treats the refactoring problem as an unsupervised graph clustering task.
- Graph Construction: Using static program analysis, they represent classes as nodes and method calls as directed edges. They enrich the nodes with attributes derived from "EntryPoints" (the APIs that trigger execution traces) and inheritance relationships.
- The Architecture: They use a 2-layer GCN encoder to create node embeddings and a GCN decoder to reconstruct the graph and its attributes.
- Joint Optimization: Unlike traditional pipelines that do embedding and clustering separately, CO-GCN uses a multi-task loss function that optimizes three things simultaneously: Structural Outlier Detection, Attribute Outlier Detection, and Clustering.
- Outlier Dilution: During training, the model uses the outlier scores to "dilute" (reduce the weight of) these nodes. This prevents messy classes from pulling distinct clusters together, resulting in much cleaner service boundaries.
Evaluation and Results
The researchers evaluated their approach on four publicly available web-based monolith applications: DayTrader, PlantsByWebSphere (PBW), Acme-Air, and DietApp. These datasets represent real-world architectural patterns across different languages and complexities.
The authors compared CO-GCN against several baselines, including standard graph embeddings (Deepwalk, Node2vec) and state-of-the-art GNNs (DGI). Key results include:
- Superior Modularity: CO-GCN consistently achieved higher Structural Modularity and Modularity scores across all four applications, indicating much tighter, more independent service clusters.
- Better Distribution: It achieved better scores in Non-Extreme Distribution (NED), meaning it avoided creating "monster services" or tiny, useless fragments.
- Human Validation: In a qualitative study with five senior software engineers, the outliers identified by CO-GCN had a 60% overlap with those identified by experts—significantly higher than the 45-55% achieved by other GNN methods.
Discussion and Conclusion
The study highlights that outliers are not just noise but "top refactor candidates." These are the specific classes a developer should split or redesign first to make the microservice transition successful. By tracking which classes are involved in specific API execution traces, the model captures the functional purpose of code, not just its raw dependency structure.
While the model currently requires a Subject Matter Expert to provide the desired number of clusters (K) and exhibits quadratic complexity relative to the number of classes, it demonstrates the power of joint learning. By training clustering and outlier detection together, the model produces robust clusters even in the presence of high-traffic, highly-connected nodes.
Summary updated