Refactoring Towards Microservices: Preparing the Ground for Service Extraction
Rita Peixoto, Filipe F. Correia, Thatiane Rosa, Eduardo Guerra, Alfredo Goldman
TL;DR
The paper tackles the challenge of migrating from monolithic systems to microservices by emphasizing code-level dependencies that complicate extraction. It proposes a seven-refactorings catalogue to systematically transform code structure and data boundaries, bridging high-level architectural guidance with actionable steps. Key contributions include concrete refactorings such as Replace Method Call with Service Call, Move Foreign-key Relationship to Code, Replicate Data Across Microservices, Split Database Across Microservices, Create Data Transfer Object, Break Data Type Dependency, and Shared Code Isolation, each with mechanics and practical examples. The work aims to enable safer, incremental migrations and lays groundwork for automation and tooling to support future migrations at scale.
Abstract
As organizations increasingly transition from monolithic systems to microservices, they aim to achieve higher availability, automatic scaling, simplified infrastructure management, enhanced collaboration, and streamlined deployments. However, this migration process remains largely manual and labour-intensive. While existing literature offers various strategies for decomposing monoliths, these approaches primarily focus on architecture-level guidance, often overlooking the code-level challenges and dependencies that developers must address during the migration. This article introduces a catalogue of seven refactorings specifically designed to support the transition to a microservices architecture with a focus on handling dependencies. The catalogue provides developers with a systematic guide that consolidates refactorings identified in the literature and addresses the critical gap in systematizing the process at the code level. By offering a structured, step-by-step approach, this work simplifies the migration process and lays the groundwork for its potential automation, empowering developers to implement these changes efficiently and effectively.
