Migrate Dubbo applications to SAE

Updated at:
Copy as MD

If your Dubbo application is already deployed on Alibaba Cloud, you can migrate it to Serverless App Engine (SAE). This topic explains how to smoothly migrate your application to SAE.

Step 1: Migrate the first application

This topic demonstrates the migration process by using a demo application. To download the demo application, see Demo.

  1. Prioritize applications for migration.

    We recommend that you start with the lowest-level provider in the call chain. If the call chain is too complex to analyze, you can start with any application.

  2. Add a dependency and modify configurations in the application.

    Note

    This migration uses the dual-registration and dual-subscription strategy.

    1. Add the edas-dubbo-migration-bom dependency to the pom.xml file.

      <dependency>
          <groupId>com.alibaba.edas</groupId>
          <artifactId>edas-dubbo-migration-bom</artifactId>
          <version>2.6.5.1</version>
          <type>pom</type>
      </dependency>                            
    2. Add the IP address of the SAE service registry to the application.properties file.

      dubbo.registry.address = edas-migration://192.168.XX.XX:9999?service-registry=edas://127.0.XX.XX:8080,zookeeper://192.168.XX.XX:2181&reference-registry=zookeeper://192.168.XX.XX:2181&config-address=127.0.XX.XX:8848      
      Important

      For non-Spring Boot applications, configure this in the dubbo.properties file or the corresponding Spring configuration file.

      Parameter

      Description

      edas-migration://192.168.XX.XX:9999

      You do not need to modify the header for multiple service registries. During startup, Dubbo validates the IP address and port. If your log level is set to WARN or lower, a WARN log message may appear, which you can ignore.

      service-registry

      The address of the service registry for service registration. You can specify multiple service registry addresses, separated by a comma (,). Each address must be in the standard Dubbo registry format. In the example, 192.168.XX.XX is the ZooKeeper address. Replace it with your actual ZooKeeper IP address and port.

      reference-registry

      The address of the service registry for service subscription. This parameter supports multiple registries or subscription to the original service registry used before the migration.

      config-address

      The address for pushing dynamic configurations.

    3. Other modifications.

      For Spring applications that do not use Spring Boot, add com.alibaba.edas.dubbo.migration.controller.EdasDubboRegistryRest to your scan path.

  3. Local verification.

    This section provides an example using dynamic configuration.

    1. Before you start the verification, complete the following steps:

    2. Verify that the service is registered.

      • Log on to the lightweight configuration and registration center and check for the service in the Provider List.

      • Log on to ZooKeeper and view the service registration and consumption information.

    3. Optional: Log on to Nacos and configure service registration information.

      Note

      If you do not need dynamic configuration, you can skip this step.

      Parameter

      Description

      DataId

      Set this parameter to dubbo.registry.config.

      Group

      Set this parameter to the name of the Dubbo application, which is specified by applicationName, such as dubbo-migration-demo-server. The configuration is at the application level, so the application name must be unique.

      Configuration content

      • Application level

        dubbo.reference.registry=edas://127.0.XX.XX:8080   # The address of the service registry for service subscription.
        dubbo.service.registry=edas://127.0.XX.XX:8080,zookeeper:127.0.XX.XX:2181   # The address of the service registry for service registration.
      • Instance IP address level

        192.168.XX.XX.dubbo.reference.registry=edas://127.0.XX.XX:8080,zookeeper:127.0.XX.XX:2181
        192.168.XX.XX.dubbo.service.registry=edas://127.0.XX.XX:8080

      When verifying a cluster, we recommend first verifying at the instance IP address level and then at the application level.

    4. Verify that application calls function correctly after migration, and check the registration and subscription status in the service registry.

      • Spring Boot 1.x: http://ip:port/dubboRegistry

      • Spring Boot 2.x: http://ip:port/actuator/dubboRegistry

      The following is an example of the service registry configuration information that is returned when you access one of the preceding endpoints:

      {
        "dubbo.effective.reference.registry": [
          "edas://127.0.xxx:8080"
        ],
        "dubbo.orig.reference.registry": [
          "zookeeper://127.0.xxx:2181"
        ],
        "dubbo.orig.service.registry": [
          "edas://127.0.xxx:8080",
          "zookeeper://127.0.xxx:2181"
        ],
        "dubbo.effective.service.registry": [
          "edas://127.0.xxx:8080",
          "zookeeper://127.0.xxx:2181"
        ]
      }
  4. Deploy the application to SAE.

    Deploy the application to SAE as needed. For more information, see Application deployment.

  5. Verify the results.

    1. Verify that your business services function correctly.

    2. Check service subscription monitoring.

      If Spring Boot Actuator monitoring is enabled for your application, access the Actuator endpoints to view the RibbonServerList information for subscribed services:

      • Spring Boot 1.x: http://ip:port/dubboRegistry

      • Spring Boot 2.x: http://ip:port/actuator/dubboRegistry

      {
        "dubbo.effective.reference.registry": [
          "edas://127.0.xxx:8080"
        ],
        "dubbo.orig.reference.registry": [
          "zookeeper://127.0.xxx:2181"
        ],
        "dubbo.orig.service.registry": [
          "edas://127.0.xxx:8080",
          "zookeeper://127.0.xxx:2181"
        ],
        "dubbo.effective.service.registry": [
          "edas://127.0.xxx:8080",
          "zookeeper://127.0.xxx:2181"
        ]
      }

      Parameter descriptions:

      • dubbo.orig.**: The service registry information configured in the application.

      • dubbo.effective.**: The effective service registry information.

Step 2: Migrate all remaining applications

Sequentially migrate all other applications to SAE. For more information, see Step 1: Migrate the first application.

Step 3: Clean up migration configuration

After the migration is complete, delete the original service registry configuration and the migration-only dependency edas-dubbo-migration-bom.

Update the service registry addresses to ensure consumers and providers subscribe only from SAE. This involves removing the ZooKeeper configuration. You can do this in one of the following ways:

  • Method 1: Use dynamic configuration. For more information, see the local verification section.

  • Method 2: Modify the configuration manually.

    After you update all applications, change the service registry address and set the subscription address to SAE Config Server.

    dubbo.registry.address = edas-migration://192.168.XX.XX:9999?service-registry=edas://127.0.XX.XX:8080,zookeeper://192.168.XX.XX:2181&reference-registry=edas://127.0.XX.XX:8080&config-address=127.0.XX.XX:8848

    Change the value of reference-registry from zookeeper://192.168.XX.XX:2181 to edas://127.0.XX.XX:8080 and then deploy the application.

    Note

    After the migration is complete, if you no longer use ZooKeeper, remove zookeeper://192.168.XX.XX:2181 from the service registry configuration.

    While continued use of the old ZooKeeper does not affect business stability, it complicates Dubbo's interaction with the service registry and may increase the error rate. We recommend removing the old ZooKeeper configuration promptly after the migration is complete, and restarting the applications in batches during off-peak hours. The final example address is as follows:

    dubbo.registry.address = edas://127.0.XX.XX:8080