Configuration in MSA
- In MSA , there can be numbers of microservices where each can have the following types of configurations and each configuration is required for different environments like Development, QA, UAT and Producation:
- Application related
- Database related
- Queues and other infrastructure resouces information
- URLs of other microservices and external services.
- Storing configuration within application should not be considered. As mentioned by the Twelve-Factor App:“Apps sometimes store config as constants in the code. This is a violation of twelve-factor, which requires strict separation of config from code. Config varies substantially across deploys, code does not.”
- So, it is always a good approach to maintain configurations in external configuration store so that the configuration can be management and control easily. Also, there should not be any dependency on the code.
- The type of external configuration store will dependent on the hosting environment so select appropriate store.
- And, external configuration can be exposed by configuration microservice(s) which can be used by other microservices to pull the configuration information. While exposing and maintaining the configuration, remember to keep confidential information encrypted. A microservice can simply use its ID along with environment detail to get the relevant configuration information.