Mikroservis yazılımlarının sürdürülebilirlik seviyelerinin ölçülmesi
Measuring the maintainability levels of microservice software
Yazar: OĞUZCAN ÖZDEMİR
Danışman: DOÇ. DR. FEZA BUZLUCA
İstanbul Teknik Üniversitesi / Lisansüstü Eğitim Enstitüsü / Bilgisayar Mühendisliği Ana Bilim Dalı / Bilgisayar Mühendisliği Bilim Dalı
Derece: Yüksek Lisans, 2024
Konu: Bilgisayar Mühendisliği Bilimleri-Bilgisayar ve Kontrol = Computer Engineering and Computer Science and Control

Özet:
Yazılım mühendisliğindeki hızlı gelişmeler ışığında, Mikroservis Mimarisi (MSA), ölçeklenebilirlik ve hızlandırılmış teslim süreçleri gibi avantajları sayesinde giderek artan bir tercih ve popülarite kazanmaktadır. MSA'nın modüler yapısı, operasyonel verimliliği ve esnekliği, kritik bir yaklaşım olarak öne çıkarmaktadır. Ancak mikroservis tabanlı sistemlerinin kalitesine ve özellikle sürdürülebilirlik ölçümlerine dair odaklanma sınırlı kalmıştır. 

Bu çalışma, mikroservis mimarilerinin sürdürülebilirliğini değerlendirmek için yenilikçi bir model önermektedir. Sunulan model, ISO/IEC 250xy'nin SQuaRE (Sistem ve Yazılım Kalite Gereksinimleri ve Değerlendirmesi) çerçevesine uygun olarak, sürdürülebilirliğin alt boyutları olan test edilebilirlik ve değiştirilebilirliğe odaklanmaktadır. Kod metrikleri analizi temelinde şekillenen bu yaklaşım, Mikroservis Mimarisinin (MSA) çeşitli özelliklerini kapsayan kod metriklerini kullanarak, mikroservislerin kalite özelliklerinine göre gruplamak için kümeleme algoritması kullanılmıştır. 

Araştırmamızda, mikroservislerin test edilebilirlik ve değiştirilebilirlik değerlerini hesaplamak için özel olarak seçilmiş bir dizi metrik kullanılmıştır. Test edilebilirlik için Sınıflar Arası Baglılık (CBO), Ortalama Parametre Sayısı (ANOP), Ortalama Fonksiyon Uzunlugu (AML) Ortalama Karmaşıklık (AC), Ortalama Blok İç İçe Geçme Derinliği (ABND), Methodlarda Tutarsızlık (LCOM) ve Servis Bağımlılık Sayısı (SDC) kullanılmıştır. Değiştirilebilirliği belirlemek için Kod Satır Sayısı (LOC), Bilişsel Karmaşıklık (CogC), Methodlarda Tutarsızlık (LCOM), Kod Tekrar Oranı (CDR) ve Kod Koku Yoğunluğu (CSD) metrikleri kullanılmıştır. 
Sunulan model dört aşamadan oluşmaktadır ilk aşamada her bir kod metriği k-means algoritması kullanılarak üç farklı seviyeye ayrılmaktadır. İkinci aşamada ilgili kod metriklerinin seviyeleri ve kümeleme algoritması kullanılarak her bir mikroservisin test edilebilirlik seviyesi ölçülmektedir. Üçüncü aşamada ise ilgili kod metriklerinin seviyeleri ve kümeleme algoritması kullanılarak mikroservisin değiştirilebilirlik seviyesi ölçülür. Hiyerarşik bir yapıda olan modelin son adımında ise elde edilen değiştirilebilirlik ve test edilebilirlik seviyeleri kullanılarak bir sınıflandırma yapılır. Yapılan sınıflandırma sonucunda her bir servisin sürdürülebilirlik derecesi ölçülür. 

Modelimizin etkinliği, mikroservis mimarisinde geliştirilmiş, açık kaynaklı proje üzerinde uygulanarak test edilmiş ve başarılı bir şekilde düşük sürdürülebilirlik değerine sahip projeler tespit edilmiştir. Ayrıca, bu yaklaşımımız alanın uzmanları tarafından yapılan değerlendirmelerle karşılaştırılarak test edilmiş ve \%83,33 Duyarlılık (recall) ve \%71,43 kesinlik (precision) değerleri elde edilerek hem etkinliğini hem de güvenilirliğini kanıtlamıştır. 

Bu araştırma, mikroservis yazılımlarının sürdürülebilirliğini değerlendirmede yenilikçi bir bakış açısı sunarak, yazılım mimarları ve geliştiriciler için değerli bir kaynak oluşturmaktadır. MSA içindeki yazılım sistemlerinin genel kalitesini ve uzun ömürlülüğünü artırmayı hedeflemektedir. Araştırmamız, mikroservislerin yaşam döngüsü içinde sürdürülebilirliğin temel önemini vurgulayarak ve bu konudaki çeşitli faktörleri aydınlatarak, özellikle Mikroservis Mimarisi bağlamında yazılım mühendisliği alanına önemli bir katkıda bulunmaktadır.

Abstract:
In the rapidly evolving world of software engineering, Microservice Architecture (MSA) is increasingly favored due to its advantages in scalability and expedited delivery processes. The modular structure of MSA highlights its operational efficiency and flexibility as a critical approach. However, the focus on the quality and, specifically, the maintainability measures of microservice-based systems remains limited.

This study proposes an innovative model for assessing the maintainability of microservice architectures. The presented model aligns with the SQuaRE (System and Software Quality Requirements and Evaluation) framework of ISO/IEC 250xy, focusing on the sub-dimensions of maintainability such as testability and modifiability. This approach, which is shaped on the basis of code metrics analysis, uses code metrics covering various features of the Microservices Architecture (MSA) and a clustering algorithm to group microservices according to their quality characteristics.

According to ISO/IEC 25010, maintainability is defined as the degree to which a product or system can be effectively and efficiently modified to improve it, correct it, or adapt it to changes in the environment and in requirements . Maintainability consists of five sub-characteristics: modularity, reusability, analyzability, modifiability, and testability . This study focuses on evaluating the maintainability of microservices, with a particular emphasis on the two critical sub-characteristics: testability and modifiability. By focusing on these sub-characteristics, the study aims to provide a more detailed understanding of how microservices can be effectively maintained and adapted to changing requirements and technical challenges.


In this model, the Quality Measurement Reference Model (QM-RM) defined in ISO/IEC 25020 was used as the foundation. QM-RM explains the interaction between a quality model and the Quality Measurement Elements (QME) and Quality Measures (QM) derived from it. By providing a methodical and comprehensive assessment of software quality, a holistic evaluation of the overall quality of a microservice product is possible.

In our study, the code metrics used served as Quality Measurement Elements (QME), while attributes like Testability and Modifiability were reflected as Quality Measures (QM). This method ensured that our evaluation metrics were based on a foundation determined by the QM-RM framework.

Based on this foundation, microservices were categorized according to their unique quality attributes using clustering algorithms. This methodology not only aids in the systematic evaluation of microservices but also identifies those that require additional focus or improvement. This study provided a dynamic and adaptable model capable of addressing the evolving needs and complexities inherent in microservice-based systems.

Modifiability is a key factor in software systems, particularly in microservice architectures. It refers to the ability to make changes to the system without causing disruptions or introducing new errors . Given the dynamic nature of microservices, which are continuously evolving and adapting to changing requirements, this is incredibly important . Microservices, which are small, independent units that communicate through well-defined APIs, must be able to be modified without impacting the overall system .

The importance of modifiability in microservice architectures is underscored by the need to perform seamless updates and changes without causing disruptions to other microservices . The independence in development and deployment of microservices implies that modifying one should not affect the others, which is vital for maintaining the autonomy of each microservice . Additionally, in distributed environments like cloud computing where microservices are frequently used, coordinating changes across multiple microservices presents challenges. Modifiability plays a critical role in facilitating this process and minimizing the risk of errors .

In microservice architecture, testability refers to how easily developers can test the microservices and the system as a whole. It is crucial for ensuring the overall quality and reliability of the system. Testing microservices, which are small and autonomous, can be challenging. However, strategies such as designing microservices with well-defined interfaces, using dependency injection, and writing unit tests can enhance the testability of microservices . Improved testability allows for rapid fault detection and resolution, ultimately leading to a more reliable system .

Testability plays a vital role in reducing the maintenance and support costs for microservices. Well-tested microservices allow developers to more easily identify and fix issues, thereby reducing the time and resources spent on system maintenance . By focusing on improving testability, developers can create more reliable and maintainable microservice software, thus enhancing its overall efficiency and effectiveness.

In our research, we utilized a selected set of metrics to calculate the testability and modifiability values of microservices. The metrics used to evaluate testability include Coupling Between Object Classes (CBO), Average Number of Parameters (ANOP), Average Method Length (AML), Average Complexity (AC), Average Block Nesting Depth (ABND), Lack of Cohesion in Methods (LCOM), and Service Dependency Count (SDC). To determine modifiability, the metrics employed are Lines of Code (LOC), Cognitive Complexity (CogC), Lack of Cohesion in Methods (LCOM), Code Duplication Ratio (CDR), and Code Smell Density (CSD). Based on these calculated values, we determined the maintainability of each microservice in accordance with ISO/IEC 25020 standards. 

Our study used the k-means algorithm to calculate the values of modifiability, testability, and sustainability. The k-means algorithm evaluated the performance of microservices in detail regarding these values. This structure is necessary to understand the performance of each microservice in terms of testability and modifiability.

Additionally, after performing clustering operations with the k-means algorithm, Silhouette score calculations were conducted to evaluate the quality and appropriateness of each cluster. The Silhouette score measures how well each data point fits within its own cluster and how distinctly it separates from other clusters, indicating the success of the clustering outcome. Through these analyses, the testability, modifiability, and sustainability levels of microservices were more clearly classified, providing essential information for optimizing these levels.

Performance measurements conducted have comprehensively evaluated the effectiveness of the proposed model in accurately identifying microservices with low maintainability. Additionally, the proposed model has successfully categorized microservices with medium to high maintainability. This demonstrates the robustness of the model in not only identifying microservices with potential maintainability issues but also in effectively assessing those with sufficient medium to high maintainability. The results validate the applicability of the model across various maintainability scenarios, with 25 out of 34 microservices aligning with expert decisions, yielding an accuracy rate of 73.53\%.

The effectiveness of our model was tested on an open-source project developed in microservice architecture, successfully identifying projects with low maintainability. Furthermore, this approach was validated against evaluations by domain experts, achieving a recall of 83.33\% and precision of 71.43\%, thus proving its efficacy and reliability.

The results of this study demonstrate the effectiveness and practical applicability of the quality model developed to evaluate the maintainability of microservices. The factors of testability and modifiability, which the model focuses on, are critical in understanding the sustainability of microservices. By using code metrics, the model has successfully determined the maintainability levels of microservices and provided developers with concrete and actionable insights.

Upon examining microservices identified as having low sustainability, it was observed that their code metrics reflected the characteristics of the project. Features such as high code dependency, long methods, and complex structures contributed to low sustainability levels. These findings indicate that the proposed model accurately identifies critical factors affecting the maintainability of microservices.

The success metrics obtained during the validation process support the reliability and effectiveness of the model. These results show that the model can accurately determine the maintainability levels of microservices and provide valuable information to developers.

In conclusion, this study highlights the importance of the metrics and approaches used in evaluating the sustainability of microservices. While studies conducted on a single project have limitations regarding generalizability to a broader microservice ecosystem, they reveal the potential of the model. Future studies aim to increase the model's generalizability and accuracy by testing it on broader and more diverse projects. This will lead to more comprehensive and reliable results in the maintainability evaluations of microservice architectures.

This research presents an innovative perspective in assessing the maintainability of microservice software, offering a valuable resource for software architects and developers. By addressing the unique challenges posed by microservice architecture, this methodology provides a systematic and quantitative approach to enhance the long-term functionality and success of software systems. Our study underscores the fundamental importance of maintainability in the lifecycle of microservices, shedding light on various factors in this regard, and making a significant contribution to the field of software engineering, particularly in the context of Microservice Architecture. This methodology plays a critical role in the performance evaluation of microservices, significantly contributing to the overall success of our project.

Furthermore, this study presents a comprehensive evaluation of microservice architecture design based on ISO/IEC 250xy standards with a hierarchical quality model. The model decomposes high-level quality attributes into measurable metrics, providing an extensive view of microservice quality. To assess the quality of microservice software, clustering algorithms were used to categorize microservices based on their quality attributes.