Micro Service Transformation Series III: Configuration Center

Summary:

  • One of the micro-service transformation series: overview
  • Micro Service Transformation Series II: Service Registration Center

Configuration Center Overview

This article is the third part of the micro-service transformation series, the theme is the configuration center. On the one we talked about the service registry, that is, by providing some kind of registration and discovery mechanism to solve the problem of service interoperability. So the question comes, how does a service know the address of the service registry? This involves the service configuration. We know that up to a PaaS platform, as small as a caching framework, generally relies on a specific configuration to provide services normally, micro services are no exception.

Configuration classification

  • According to the configuration of the source, the main source code (commonly known as hard-code), files, databases and remote calls.
  • According to the configuration of the applicable environment, can be divided into development environment, test environment, pre-release environment, production environment.
  • According to the configuration of the integration phase, can be divided into compile-time, packaging and runtime. Compiler, the most common there are two, one source-level configuration, the second is the configuration file and the source code submitted to the code warehouse. When packaged, that is, in the application package phase in some way the configuration (usually in the form of files) into the final application package. Runtime, refers to the application does not know the specific configuration before starting, but at startup, first from the local or remote access configuration, and then start the normal.
  • According to the configuration of the loading method can be divided into single-load configuration and dynamic loading configuration.

Evolution

With the increase in business complexity and the evolution of technical architecture, the application of the configuration also put forward higher and higher requirements. A typical evolution process is often the case, at first all the configuration with the source code together in the code warehouse; after security considerations, the configuration file from the code warehouse to separate, or on the CI server through the package script Into the application package, or directly into the application to run the server's specific directory, the remaining non-file form of the key configuration is stored in the database. In this way, in the monomer application stage is very common, and often can run very well, but to the micro-service stage, the face of explosive growth in the number of applications and the number of servers, it seems powerless. At this time, it turned to the configuration center to show their talents. What is the configuration center? In simple terms, it is a basic service component that unifies the various application configurations.

Optional frame

Selection of a qualified configuration center, at least need to meet the following four core needs:

  • Non-development environment application configuration confidentiality, to avoid the key configuration to write the source code
  • The isolation of application configurations in different deployment environments, such as non-production environments, can not be used in production environments
  • Consistency of the server application configuration in the same deployment environment, that is, all servers use the same configuration
  • The manageability of application configuration in a distributed environment, that is, the ability to provide remote management configuration

Now the open source community mainstream configuration center framework with Spring Cloud Config and disconf, both meet the above four core needs, but the difference.

Spring Cloud Config

spring-cloud-config.png
Spring Cloud Config can be said to be a tailored lightweight configuration center for the Spring, cleverly applied to the application environment mapping profile, application version mapping for the label. On the server side, based on a specific external system (Git, file system or vault) storage and management application configuration; in the client, the use of powerful Spring configuration system, at runtime load application configuration.

Disconf

disconf.jpg
Disconf is a former Baidu senior R & D engineers Liao Qiyi open source works. In the server, providing a complete interface to manage a variety of operating environments, applications and configuration files; in the client, the depth of integration Spring, through the Spring AOP application configuration to achieve automatic loading and refresh.

Program selection

Whether it is Spring Cloud Config or disconf, the default client is deeply bound to the Spring framework, which for non-Spring applications will undoubtedly increase the integration costs, even if they provide access to the application configuration API. Finally, we still use the micro-service transformation before the development of the Matrix as a configuration center, on the one hand, you can keep the old and new systems using the same set of configuration services to reduce maintenance costs, on the other hand, to meet the four core needs under the premise, Matrix also offers some unique abilities.

  • Separate configuration files and configuration items. For the configuration file, through the various types of supporting package plug-in (sbt, maven, gradle), the package will be packaged into the application package, while minimizing the intrusiveness of CI; for configuration items, provide SDK, help from the application To obtain a configuration item, while supporting a simple cache mechanism.
  • Increase the application version dimension, that is, for the same application, you can in the server for different versions or version of the interval to maintain a different application configuration.
  • Application configuration versioning support, similar to Git, can be any application configuration back to any historical version.

For further information, refer to the Matrix design document I wrote earlier.
matrix.png
Matrix Architecture

Next I will introduce you to the micro-service architecture of another basic component – authorized center, so stay tuned!

reference

  • Spring Cloud Config
  • Disconf
  • Matrix

    Heads up! This alert needs your attention, but it's not super important.