Skip to main content

Why do you need Spring Cloud Config server?

Last month I wrote a primer on concepts around 12 factor app. Before getting into the details of the Spring Cloud Config Server, I must refresh on the principle #3 from the list presented in that post.

3 – Configuration
Store config in the environments

Configuration information must be separate from the source code. This may seem so obvious, but often we are guilty of leaving critical configuration parameters in the scattered in the code. Instead, applications should have environment specific configuration files. The sensitive information like database password or API key should be stored in these environment configuration files in encrypted format.

 The key takeaways from this postulate for a cloud-native microservices application are:
  1. Do not store configuration as part of the deployable unit (in the case of lead microservice - inside the jar or war if you are still deploying war like the good old days). Instead, store it in an external location and make it easily accessible during run-time. 
  2. Configuration files should be separated based on the environment where the microservice is going to run. For example - it is a common practice to maintain environment-specific configuration files like "DEVELOPMENT", "TEST","STAGING", "PRODUCTION" etc.
  3. It is a very common practice to store sensitive information like user id and password for database etc as hard coded in plain text format. It is advised to store such information in environment specific files but in an encrypted format. 
  4. Change in the configuration should not result in application/service to go through the entire build, test, release and upgrade cycle. 
So, you may think that you will have to develop a server based configuration management system. Wait, we already have a solution. Spring Cloud Config Server solves the problems described above and more. Essentially Spring Cloud Config Server is an infrastructure microservice accessible over HTTP. 

Key Features of Spring Cloud Config Server 
  1. Enables centralized configuration management for all environments and different applications.
  2. Provides server based configuration management accessible over HTTP/HTTPS
  3. Configuration information is stored in repositories managed by the config server. 
  4. Provides client-side support for applications to access the configuration properties at startup and cache them. 
  5. Configuration properties can be version controlled depending on the underlying repository support. 
  6. Any changes to configuration properties/values can be propagated to all the client applications. The client side support allows these changes to be applied transparently / refreshed without the need to restart the application again. 
  7. Confidential information can be encrypted. 
  8. Maps to Spring core concepts of Environment, PropertySource, Profile and Value. Thus it is easy to use in Spring applications and microservices.
  9. Facilitates continuous delivery pipelines by supporting configuration for different environments.
  10. It can be used by applications running in any language as the config server is nothing more than a REST endpoint serving configuration managed by an underlying repository. For example.NET clients can also use Spring Cloud Config Server. (More details can be found here - 
  11. Supports Git as the primary storage repository for configuration. However other repositories like a file system, Hashicorp Vault are also supported out of the box. The support for MongoDB is in incubation as of this writing. 
  12. Monitoring of the config server is also possible. 
  13. Easy to configure and launch.
  14. Can be easily containerized. 
Limitations of Spring Cloud Config Server
  1. Properties are not cached on the server side.
  2. Each request leads to calls to the backing repository which can lead to multiple remote calls.
  3. High availability and failover features are limited. 
  4. Dynamic update of configuration properties on the server is very cumbersome. 
Note, that config server is extremely performant unless limited by the underlying store. The benefits overweigh the concerns and hence Spring cloud config server is the recommended tool to manage configuration in the microservices ecosystem.

Spring Cloud Config Server Alternatives
  1. Commons Configuration
  2. Netflix Archaius
  3. Apache ZooKeeper
  4. Kubernetes ConfigMap
  5. Consul Configuration
Note that none of these alternatives map to Spring Environment, PropertySource or Profile. Hence it will require a lot of plumbing to provide the features provided by Spring Cloud Config Server. So Spring Cloud Config Server is our tool of choice for configuration data management in the cloud-native architecture. 
Taking stock
So far I have covered only a few pieces of the Spring cloud-native application architecture jigsaw. I have only written about Spring Boot for microservices development and now I am going to write about Spring Cloud Config Server. I will gradually cover all the boxes in figure 1, to complete all the puzzles in the jigsaw. 

Figure 1 - Spring Cloud Jigsaw
Whats's next?

This post was dedicated to some theory behind, the Spring Cloud Config server. In the next post I will get back to hands-on work again and setup the Spring cloud config server and test it using a simple browser based client. Stay tuned for more exciting stuff. 


Popular posts from this blog

Changing the root web application in Tomcat 6

These days I am very busy developing a large and complex web application, which is nearing its first release. This web based product runs on Tomcat 6 and will be deployed on
But if I deploy my web application on Tomcat 6, I need to specify the context root. Well this is no good, why will the users of this website be willing to remember the context root. What if the context root changes. In other words the users would not be interest in typing the following - to visit this site.
Hence it is necessary that I change the default / root web application of Tomcat and point it to my application. I wanted to try and test this on localhost first. As always I Googled and found a number of posts and none seem to work. I also read the documentation it was helpful in understanding the concepts but was not effective as I could not get it working. Finally after few hours of trial and error one of my colleague Joyeeta Majumdar found the so…

Part 3 - Integrating Tiles, Thymeleaf and Spring MVC 3

In this post I will demonstrate how to integrate Apache Tiles with Thymeleaf. This is very simple. The first step is to include the tiles and thymeleaf-tiles extension dependencies. I will include them in the pom.xml. Note we wil lbe using Tiles 2.2.2Listing 1 - parent/pom.xml --- thymeleaf-tiles and tiles dependencies <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Tiles -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->