Community Blog Spring Cloud-based Application Configuration Management with Alibaba Cloud ACM

Spring Cloud-based Application Configuration Management with Alibaba Cloud ACM

In this article, we'll discuss how Alibaba Cloud's cloud native Application Configuration Management (ACM) tool makes managing Spring Cloud-based applications easy.

In a conventional architecture, if any configuration information changes, we usually need to log on to the server and manually modify the configuration for the configuration take effect. In a microservices architecture, the number of applications and nodes increases sharply due to the rapid growth of microservices. As a result, applications are published more and more frequently, making configuration changes more difficult. The common practice is to abstract the application configurations and place them in an external configuration center to automate the configuration changes. However, this type of native solution has serious dependency and high release delay problems.

Standard Configuration Management Methods and Problems in Spring Cloud

Spring Cloud provides the Spring Cloud Config component to manage the configuration by default.

For the working mechanism of Spring Cloud Config, see the following diagram:


Unlike the conventional method of manually modifying configuration on production servers one by one, the method supported by Spring Cloud is much easier. If your configuration changes, you can modify the configuration in Git, and then use the Spring Cloud Config Server to dynamically distribute the configuration to each of the servers. The process is as follows:

  • The user updates and commits the configuration in Git.
  • Spring Cloud Config Server gets the latest configuration by using the callback function.
  • The user performs a configuration refresh operation on any of the servers ("post /bus/refresh" as shown in the diagram).
  • The target server (App A) pulls the latest configuration from the Config Server, and sends a message to the message bus to notify other servers that the configuration has been changed.
  • After all other servers are informed of the configuration update through the message bus, they pull the latest configuration from the Config Server.

Now, the configuration modification is finished.

The Spring Cloud Config component successfully solves the cumbersome O&M problems of static configuration in the configuration center. However, Spring Cloud Config still has the following drawbacks:

  • The standard solution relies on Git. Although other storage options are available, the standard Git solution is controversial. After all, Git is not commonly used in the industry and is rarely used in critical production environments (with the exceptions of the development and test environments);
  • Configuration changes rely on Cloud Bus. The architecture is complex and there are configuration consistency issues.
  • The timeliness of the entire process is low. It has a lengthy publishing process which involves multiple asynchronous operations. From the publishing of the configuration change to the time when the configuration takes effect on all servers, the delay could be minutes.

Alibaba Cloud ACM Optimizes Configuration Management for Spring Cloud

Alibaba Cloud Application Configuration Management Service (ACM), as a cloud implementation of Nacos, can optimize the preceding configuration management problems. With ACM, the configuration modification becomes extremely simple and efficient, as shown in the following diagram.


The entire process is divided into two steps:

  • The user modifies the configuration in ACM;
  • ACM dynamically pushes the modification to all applications.

ACM is fully compatible with Spring framework APIs, including Spring Framework, Spring Boot, and Spring Cloud. ACM for Spring Cloud, compared to Spring Cloud Config, has a number of benefits due to the simplified architecture:

  • High configuration change push performance. According to the internal performance statistics from Alibaba, in most cases, the configuration push takes effect within 0.5 seconds. In 99.9% of cases, a configuration change can be pushed to thousands of machines within 3 seconds.
  • Simple operation and maintenance. No additional Git storage or Cloud Bus components are required. A single configuration API can implement all configuration center functions.
  • Following the open source spirit, ACM is the cloud based implementation of Nacos, and does not require additional cost to use any of its functions.

Spring Cloud users can seamlessly migrate the configuration management of Spring Cloud applications to ACM by using the API provided by Spring Cloud Config. This greatly improves the configuration management agility of microservices applications running in the Spring Cloud framework. ACM has several additional useful features in comparison with Spring Cloud Config, such as security compliance assessment of cloud configuration, phased release of configuration, and rollback.

How Can We Quickly Deploy ACM?

For Spring Cloud users who need to switch from Spring Cloud Config to Alibaba Cloud ACM, no additional changes to the business code is required. Spring Cloud’s @Value annotation is valid in ACM. Users only need to modify two compilation configuration files of the Spring Cloud application.

1.  Modify the configuration file

Add the ACM connection address and authentication information in bootstrap.properties, as shown in the following example. Parameters such as endpoint, namespace, accessKey, and secretKey can be obtained directly on the ACM console.


After the spring.application.name and spring.cloud.nacos.config.file are specified, the configuration name on the ACM console is determined. In the preceding example, the configuration name is com.alibaba.nacos.example.properties.

2.  Add the nacos starter dependency into pom

See the following snippet:


After completing the above two modifications, re-package and compile the Spring Cloud program to switch to ACM configuration management.

Spring Cloud Code and Configuration Change

The /echo API returns the value of the dynamic configuration parameter configValue.


Package and run the following code snippet. Add the configuration on the corresponding ACM console. Set the corresponding configuration name DataID (in this case com.alibaba.nacos.example.properties), and click Publish.


Finally, run the curl command locally, assuming that the http monitoring port is 8080:


The following will be returned:


If the true value is returned the configuration is successful. For detailed program examples, see ACM official documentation.

0 0 0
Share on

Alibaba Clouder

2,605 posts | 744 followers

You may also like


Alibaba Clouder

2,605 posts | 744 followers

Related Products