On the Cohesion of Hub-like microservices
Abstract
Microservice architecture has gained traction as a powerful way to build distributed, scalable systems. However, analyzing its quality requires considering aspects unique to this architectural style. In particular, cohesion of microservices is considered important for evaluating microservice maintainability and quality, while few such metrics are available. Hub-like microservices are defined as an architectural anti-pattern, assumed to emerge when services centralize too many dependencies or responsibilities, thereby exhibiting low cohesion. However, this assumption has not been empirically validated. This study investigates whether Hub-like microservices indeed display lower internal cohesion than other services. We analyzed 123 microservices from a dataset of 25 microservice systems by leveraging an existing labeling of Hub-like microservices and computing eight cohesion metrics. We examined correlations between cohesion and several Hub-like detection techniques, including centrality and clustering-based metrics, the Minimum Description Length principle, and the Arcan approach. Our findings reveal weak to moderate negative correlations between service interface data cohesion and network centrality. Conversely, class relation cohesion is positively correlated with clustering-based Hub-like indicators, as well as shows a relation to all categorical Hub-like indicators with a positive effect size, due to the opposite interpretation of this metric. Thus, the common assumption that Hub-like services suffer from poor internal cohesion is not supported by our findings, with only a specific combination of a Hub-like detection method and a cohesion metric behaving as conjectured.