计算机科学 ›› 2026, Vol. 53 ›› Issue (11A): 251100111-1023.doi: 10.11896/jsjkx.251100111

• 计算机软件&体系结构 • 上一篇    下一篇

面向方法粒度的微服务自动识别与优化方法研究

钟林辉1, 李卓宇1, 郑燚1, 孙文彬1, 李方云1, 黄淇轩2, 陈尚阳1   

  1. 1 江西师范大学人工智能学院 南昌 330022
    2 中国移动通信集团江西有限公司抚州分公司 江西 抚州 344399
  • 出版日期:2026-11-16 发布日期:2026-11-16
  • 通讯作者: 郑燚(003265@jxnu.edu.cn)
  • 作者简介:(003265@jxnu.edu.cn)
  • 基金资助:
    国家自然科学基金(62062039,61966017);江西省自然科学基金(20212BAB202017,20224BAB202013,20212BAB202018);江西师范大学教学改革研究课题(JXSDJG2301,JXSDJG2044)

Research on Automatic Identification and Optimization Method for Microservices at the Method Level

ZHONG Linhui1, LI Zhuoyu1, ZHENG Yi1, SUN Wenbin1, LI Fangyun1, HUANG Qixuan2, CHEN Shangyang1   

  1. 1 College of Artificial Intelligence,Jiang Xi Normal University,Nanchang 330022,China
    2 China Mobile Communications Group Jiangxi Co.,Ltd.Fuzhou Branch,Fuzhou,Jiangxi 344399,China
  • Published:2026-11-16 Online:2026-11-16
  • About author:ZHONG Linhui,born in 1974,Ph.D,associate professor,is a member of CCF(No.09772M).His main research interests include software architecture,software evolution,and maintenance.
    ZHENG Yi,born in 1974,master.His main research interests include compu-ter system architecture and the development of software and hardware platforms for embedded systems.
  • Supported by:
    This work was supported by the National Natural Science Foundation of China(62062039,61966017),Natural Science Foundation of Jingxi Pro-vince,China(20212BAB202017,20224BAB202013,20212BAB202018) and Teaching Reform Research Project of Jiangxi Normal University(JXSDJG2301,JXSDJG2044).

摘要: 微服务架构是一种典型的分布式架构风格,强调服务通过通信机制进行交互,将单体应用向微服务架构转换可以提升系统的可维护性与可扩展性。然而,现有的自动识别微服务方法存在基于类粒度划分导致的细粒度功能关联捕捉不足,以及相似性计算忽视多维度特征等问题。为此,提出面向方法粒度的微服务自动识别与优化方法,通过融合语义、术语和结构三维度信息,提升划分精度。在语义层面,利用CodeT5+模型生成语义向量,计算余弦相似度;在术语层面,提取方法名、参数等构建向量并计算相似性;在结构层面,分析调用关系与参数依赖,采用Jaccard系数衡量关联性。基于此构建相似度矩阵,使用层次聚类生成初步划分方案。进一步引入遗传算法进行多目标优化,最大化消息级内聚性和结构模块化质量,有效降低服务间耦合。同时设计类重组策略,将相关方法合并或垂直拆分,提升功能独立性。实验结果表明,该方法在准确率、内聚性和模块化质量方面优于传统方法,实现了高效、精准的自动化微服务划分。

关键词: 微服务识别, 遗传算法, 层次聚类, 多目标优化, 代码相似性

Abstract: Microservices architecture is a distributed style where services interact via communication mechanisms;migrating mo-noliths to it improves maintainability and scalability.Existing automated decomposition methods suffer from coarse class-level granularity,which misses fine-grained functional relations,and from similarity measures that ignore multi-dimensional features.This paper proposes a method-granularity approach that fuses semantic,lexical,and structural information to improve partitioning accuracy.Semantic similarity uses CodeT5+ embeddings and cosine similarity;lexical similarity is based on method names and parameters;structural similarity analyzes call relations and parameter dependencies using Jaccard coefficients.A similarity matrix from these dimensions drives hierarchical clustering for an initial partition.A genetic algorithm then performs multi-objective optimization to maximize message-level cohesion and structural modularity while reducing inter-service coupling.A class restructuring strategy merges or vertically splits related methods to enhance functional independence.Experimental results show the method outperforms traditional approaches in accuracy,cohesion,and modularity,achieving efficient and precise automated microservice decomposition.

Key words: Microservice identification, Genetic algorithm, Hierarchical clustering, Multi-objective optimization, Code similarity

中图分类号: 

  • TP311
[1] 刘江鹏.基于项目驱动的微服务架构实验教学设计[J].信息系统工程,2025(10):165-168.
[2] HUSSEIN S,LAHAMI M,TORJMEN M.Assessing the quality of microservice and monolithic architectures:systematic literature review[J].Operational Research in Engineering Sciences:Theory and Applications,2024,7(2):417-446.
[3] GYSEL M,KÖLBENER L,GIERSCHE W,et al.Service cutter:A systematic approach to service decomposition[C]//Ser-vice-Oriented and Cloud Computing:5th IFIP WG 2.14 European Conference(ESOCC 2016).Springer,2016:185-200.
[4] SAIDANI I,OUNI A,MKAOUER M W,et al.Towards automated microservices extraction using muti-objective evolutionary search[C]//Service-Oriented Computing:17th International Conference(ICSOC 2019).Springer,2019:58-63.
[5] SELLAMI K,OUNI A,SAIED M A,et al.Improving microservices extraction using evolutionary search[J].Information and Software Technology,2022,151:106996.
[6] CARVALHO L,GARCIA A,COLANZIT E,et al.On the performance and adoption of search-based microservice identification with tomicroservices[C]//2020 IEEE International Confe-rence on Software Maintenance and Evolution(ICSME).IEEE,2020:569-580.
[7] TRABELSI I,MOHA N,GUÉHÉNEUC Y G,et al.Magnet:Method-based approach using graph neural network for microservices identification[C]//2024 IEEE 21st International Conference on Software Architecture(ICSA).IEEE,2024:1-11.
[8] LI Q,LI B,MERCATI P,et al.RAMBO:Resource allocation for microservices using Bayesian optimization[J].IEEE Computer Architecture Letters,2021,20(1):46-49.
[9] PENDYALA K V N S,BUYYA R.An Infrastructure Cost Optimised Algorithm for Partitioning of Microservices[J].arXiv:2408.06570,2024.
[10] KINOSHITA T,KANUKA H.Enhancing Automated Micro-service Decomposition via Multi-Objective Optimization[J].IEEE Access,2024,12:55697-55710.
[11] GrammarT5:Grammar-integrated pretrained encoder-decoder neu-ral model for code[C]//IEEE/ACM 46th International Confe-rence on Software Engineering.2024:1-13.
[12] BORGEAUD S,MENSCH A,HOFFMANN J,et al.Improving language models by retrieving from trillions of tokens[C]//International Conference on Machine Learning.PMLR,2022:2206-2240.
[13] RAHIMI I,GANDOMI A H,CHENF,et al.A review on constraint handling techniques for population-based algorithms:from single-objective to multi-objective optimization[J].Archives of Computational Methods in Engineering,2023,30(3):2181-2209.
[14] ABDULLAH J M,RASHID T A,MAAROOFB B,et al.Multi-objective fitness-dependent optimizer algorithm[J].Neural Computing and Applications,2023,35(16):11969-11987.
[15] SHAPIRO J.Genetic algorithms in machine learning[M]//Advanced Course on Artificial Intelligence.Berlin:Springer,1999:146-168.
[16] DEB K,AGRAWAL S,PRATAP A,et al.A fast elitist non-dominated sorting genetic algorithm for multi-objective optimization:NSGA-II[C]//Parallel Problem Solving from Nature PPSN VI:6th International Conference.Berlin:Springer,2000:849-858.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!