Updated on 2025-05-07 GMT+08:00

Architecture Modernization

Microservice-based reconstruction and migration to the cloud

It is a complex process to conduct microservice-based reconstruction on a traditional monolithic application and migrate it to the cloud environment. The following describes the basic steps and considerations for microservice reconstruction and migration to cloud.
  1. Evaluate existing applications and objectives:

    First, evaluate the traditional monolithic application to understand its architecture, functions, and performance. Then, specify the goals you want to achieve in the cloud environment, such as scalability, high availability, and flexibility. This evaluation phase helps you determine whether the application is suitable for microservice reconstruction and migration to the cloud.

  1. Decompose monolithic applications

    Before microservice reconstruction, you need to decompose a monolithic application into smaller and independent functional modules. This process is often referred to as decomposing monoliths. By analyzing the service logic and functions of an application, you can identify the modules that can run independently and divide them into different microservices. Each microservice is responsible for specific service functions and should be loosely coupled and independent of each other as much as possible.

    You can use different rules to decompose an application, for example, decomposing based on service domain (domain-driven design) or decomposing based on functional module. Ensure that each microservice has clear responsibilities and defines the interaction mode between microservices through interfaces.

  1. Define service boundaries and interfaces

    After decomposition, define the boundary and API of each microservice. Determine the external interfaces of each microservice and the communication methods between them (for example, using RESTful APIs or message queues). When defining interfaces, ensure that they are clear, consistent, and easy to use. This facilitates collaboration between teams and supports future expansion and changes.

    In addition, consider using open standards and protocols, such as the OpenAPI specification (formerly known as Swagger) to define interfaces. This simplifies the integration between microservices and facilitates document generation and code generation.

  1. Design and implement service governance design and implementation

    In the microservice architecture, service governance becomes critical. You need to consider how to discover, register, configure, and monitor your microservices. Select service registration and discovery tools (such as Consul and Eureka) that meet your requirements and ensure that microservices can be effectively managed, monitored, and maintained throughout the service lifecycle. The service registration and discovery tool helps you automate the service registration and discovery process and provides functions such as service health check and load balancing.

    In addition, load balancing, fault recovery, and service security should be considered. The load balancing mechanism is used to balance request distribution to ensure that each microservice can process a proper amount of load. Implement a fault recovery mechanism (such as circuit breaker mode) to handle faults and prevent cascading faults. In addition, proper authorization and authentication mechanisms are used to protect microservice security and restrict access to sensitive data and functions.

  1. Containerization technology introduction

    The microservice architecture is usually deployed and managed using the containerization technology. The most common method is to use Docker containers. Each microservice is packaged into an independent container for better isolation and deployment. Container orchestration tools (such as Kubernetes) are used to automate container deployment, scaling, and management, improving system scalability and elasticity. Containerization enables more flexible deployment and management of microservices. Containerization also helps to solve the consistency problem between the development environment and the production environment. The development team can use the same container to run microservices locally and ensure that the microservices run properly in the development and test phases. Then, these containerized microservice images are uploaded to the cloud platform for deployment and production.

  1. Data management and persistence

    When converting monolithic application to a microservice, you need to consider data management and persistence. Each microservice may have its own database or share the same database. Select a database solution that meets your requirements and ensure data consistency and reliability. In the cloud environment, you can use hosted database services, such as Huawei Cloud RDS and GaussDB. In addition, you need to consider how to handle data transactions and data consistency across multiple microservices. A common method is to use a distributed transaction manager (such as the Saga mode) to ensure that data operations between microservices are consistent and atomic.

  1. Monitoring and logging

    For the microservice architecture, it is important to implement comprehensive monitoring and logging. Use appropriate monitoring tools and log systems to collect and analyze metrics and logs of each microservice, as well as performance and fault information of the entire system. This helps you quickly detect and resolve potential problems and ensures system availability and stability. You can use the monitoring and log services provided by cloud providers, such as Huawei Cloud Eye and LTS, to centrally manage and analyze monitoring data and logs. In addition, the visualization and alarm mechanism enables the team to monitor the system running status in real time and take measures in a timely manner when an exception occurs.

  1. Automatic deployment and CI/CD

    The microservice architecture usually needs to be frequently deployed and updated. To simplify and accelerate the deployment process, automatic deployment and continuous integration/continuous delivery (CI/CD) processes can be introduced. Use appropriate tools and technologies, such as Jenkins and GitLab CI/CD, to automate the build, test, and deployment processes. The automatic deployment and CI/CD process may include a series of steps such as code compilation, unit test and integration test running, container image building and pushing, and deployment to a cloud environment. This can speed up delivery, reduce human errors, and provide reliable deployment pipelines.

  1. Security and permissions management

    In the microservice architecture, security is an important consideration. Ensure that each microservice has an appropriate access control and permission management mechanism to prevent unauthorized access and data leakage. Identity authentication and authorization technologies (such as OAuth and JWT) can be used to verify the validity of requests and transfer identities between microservices. In addition, proper network security measures, such as firewalls and SSL/TLS encryption, are taken to protect communication between microservices. In addition, security review and vulnerability scanning are performed periodically to ensure system security and reliability.

  1. Progressive migration

    It is a complex process to reconstruct traditional monolithic application microservices and migrate them to the cloud, which may take some time and resources. To reduce risks and interruptions, you can use the progressive migration method.

    First, select a small and relatively independent module for microservice reconstruction and cloud migration. Through this lab project, you can verify the feasibility of architecture design, technology selection, and processes, and learn valuable experience and lessons. After the first module is successfully migrated, other modules are gradually reconstructed and migrated. Progressive migration also helps you gradually develop your team's capabilities and familiarize yourself with new architectures and tools. In addition, you can collect feedback and continuously adjust and optimize the system to ensure smooth reconstruction.

To sum up, microservice reconstruction and cloud migration are complex and critical processes. Multiple aspects need to be considered, such as architecture design, splitting, API definition, service governance, containerization, data management, monitoring and logging, automatic deployment, and security. By evaluating existing applications and objectives, split a monolithic application into independent microservices, introduce appropriate technologies and tools, and use the progressive migration method. Then, you can successfully transform the traditional monolithic application into a highly scalable, elastic, and reliable microservice architecture, and migrate it to the cloud.

Microservice architecture optimization

We often see that the services of some Internet enterprises develop rapidly. Software engineers of different service units continuously add new microservices or repeatedly develop microservices that implement the same service functions. As a result, the microservice architecture is disordered, which severely affects the TTM and makes fault locating time-consuming, in the face of the disordered microservice architecture, the following optimization policies can be used to shorten the time to market (TTM) and improve the fault locating efficiency:

  1. Evaluate the existing architecture. First, comprehensively evaluate the current microservice architecture. Understand the overall architecture, dependencies between services, communication protocols, and data flows. This will help you sort out the complexity of the architecture and identify the key areas for improvement.
  2. Reconstruction and splitting: Based on the evaluation result, reconstruct and split the existing microservices. Identify services that are too large, have unclear responsibilities, or are highly coupled, and split them into smaller, more focused units. This simplifies the system structure and improves maintainability.
  3. Service governance: Use a proper service governance mechanism to manage the microservice architecture. Technologies such as service registration and discovery, load balancing, and fuses are used to enhance service visibility, elasticity, and stability. This helps reduce faults and delays and improve fault locating efficiency.
  4. Implement automated testing: Establish a comprehensive automated testing strategy and tool chain. Automated testing at all levels, such as unit testing, integration testing, and end-to-end testing, can quickly capture and solve problems, ensuring that modifying a service does not affect other services.
  5. Emphasis on documentation and standards: Establish clear documentation and standards, including architecture design specifications, interface specifications, and development specifications. This helps team members understand the overall architecture and follow consistent practices during development. Documentation and standards can also help new team members adapt and contribute more quickly.
  6. Real-time monitoring and logging: The real-time monitoring and logging system is introduced to collect and analyze the running status and performance metrics of microservices. In this way, potential problems or exceptions can be detected in a timely manner, and the problems or exceptions can be quickly located and resolved. In addition, a proper alarm mechanism can help you quickly respond to faults and exceptions.
  7. Continuous delivery and deployment: Use continuous integration and continuous delivery (CI/CD) tools and processes to automate the build, test, and deployment of microservices. This will shorten the release cycle, reduce release risks, and accelerate the rollout of new features and fixes, thereby improving TTM.
  8. Establish cross-team collaboration: Encourage cooperation and communication between different teams, especially in the microservice architecture. Facilitate knowledge sharing, problem collaboration, and experience exchange, accelerate problem locating and resolution, and avoid repeated work.

These optimization policies can gradually improve the disordered microservice architecture, shorten the TTM, and improve the fault locating efficiency. The optimization of the microservice architecture is a continuous process, which requires continuous evaluation, adjustment, and improvement.