External Configuration



Problem Statement

Microservice architecture structures an application as a set of loosely coupled microservices and each service can be developed independently in agile manner to enable continous delivery/deployment. These services often interacts with infrastructure services or 3rd party services.

Insfrastructure services may include a service registry, a message broker, database server. 3rd party services can be payment services, email services, messaging services. Apart from varying services, environments often vary. Consider the following cases −

  • Configuration Data − Configurations to external/3rd party services should be provided to the micro services e.g. database credentials, network urls etc.

  • Multiple Environments − There are often varying environments like dev, qa, test, staging or pre-prod and production. A service should be deployed on each environments without any code modifications.

  • Varying configuration data − Configurations to external/3rd party services also varies from dev to production e.g. dev databse to production database, test payment processor vs original payment processor services.

Solution

We can externalize all configurations from database credentials to network urls. Service will read the configuration data during startup e.g. from a properties file/ system environment variables or using command line arguments. This pattern helps in deploying the microservices without any modification/recompilation needed.

Advertisements