Migrate a registry
If you are already using another registry, you can migrate to the SOFA registry in two ways:
Use a data synchronization component to replicate data between the two registries. This method requires deploying an additional synchronization component. The benefit of this method is that it is transparent to your application, which lets you complete the migration by directly modifying the registry dependencies and configurations.
Use the dual-registration feature of Spring Cloud to gradually migrate by modifying your application. This method is suitable if you cannot or prefer not to use a synchronization component.
This topic describes the second method.
Dependencies and configurations for dual registration
To use two registries in a Spring Cloud project, perform the following configuration steps:
Import the starters for both registries.
<dependency> <groupId>com.alipay.cloud</groupId> <artifactId>spring-cloud-starter-sofa-registry</artifactId> </dependency> <!-- For example, Nacos --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency> <!-- Other required dependencies (such as the load balancing module) -->
Configure the corresponding parameters for each registry.
spring.cloud.nacos.server-addr=127.0.0.1:8848 spring.cloud.nacos.discovery.namespace=publicAdd the following configuration to the
application.propertiesfile:spring.cloud.sofa.multi-registry.enabled=true
After you complete these steps, the dual-registration feature is enabled. This has the following effects:
The service registers with both registries.
The service discovers services from both registries. However, the service lists from the registries are not merged. Instead, the registries are traversed in order, and the service list from the first registry where the service is found is returned. By default, the SOFA registry is searched first.
Switch back to a single registry
To switch from dual-registration mode to a single registry, perform the following steps:
Delete the unnecessary registry dependency.
Delete the unused registry configuration.
Delete the configuration that disables the auto-configuration class.
Registry migration process
This section uses a simple scenario to illustrate the process of migrating a registry using dual registration. Assume that Provider A is called by Consumer A and Consumer B. All three applications are gradually modified to use dual registration.

The following procedure describes how to programmatically migrate from other registry centers to the SOFA Registry Center:
Gradually modify the applications to use the dual-registration mode. This registers them with both the original registry and the SOFA registry.

When all applications are modified to use dual registration, the SOFA registry contains the complete service information. All subscription relationships are also established in the SOFA registry. By default, subscriptions to the SOFA registry are prioritized if you have not changed the subscription priority.
NoteIn dual-registration mode, subscriptions are made to both registries simultaneously. Therefore, the order of modification does not matter. You do not need to modify the provider first, and service discovery is not affected. This example describes only one possible scenario.
After all applications are modified to use dual-registration mode and are running stably, you can gradually modify them again to use only the SOFA registry.

Performance impact
Adding the SOFA registry to your project does not affect the performance of service invocations. This is because subscriptions in the SOFA registry are fully asynchronous. The service list is cached locally, which prevents service lookups from causing performance degradation. In addition, using the subscription prefetch feature provided by Spring Cloud SOFA can further prevent service subscriptions from impacting request performance.
Limits
Spring Cloud SOFA Registry supports two load balancing frameworks: LoadBalancer and Ribbon. Dual-registration support differs between these two frameworks:
LoadBalancer is the primary load balancing framework recommended by Spring Cloud. It is designed to work with multiple registries simultaneously. This lets you combine more than two registries. This functionality requires the registry integration module to follow the Spring Cloud extension specifications, a standard that both SOFA and mainstream open source registries support.
Ribbon does not natively support using two registries simultaneously. Spring Cloud SOFA includes a compatibility design for Ribbon that enables it to be used with another registry. Therefore, if you use Ribbon as the load balancing framework, you can only use SOFA in combination with one other registry. You cannot use more than two registries.
Priority for service subscription lookups
In dual-registration mode, the SOFA registry has a higher subscription priority than other registries. This is an intentional design to facilitate migration. If you want to adjust this priority, you can add the following configuration to the application.properties file:
# Adjust the priority of SOFA service discovery. A larger value means a lower priority.
spring.cloud.sofa.discovery.sofa-discovery-client-order=100By default, the service discovery priority for various open source registries is set to 0. For example, the default value is 0 for Nacos, Consul, Eureka, and Zookeeper. Therefore, setting a value greater than 0 gives the open source framework a higher priority. If this does not work as expected, confirm the priority settings of the other registry.
Priority adjustment is supported only when you use LoadBalancer for load balancing. This feature is not supported for Ribbon.