What is Centralized Configuration in Microservices?
Centralized Configuration in Microservices is a configuration management approach where all application configuration properties are stored and managed from a single centralized server or repository instead of maintaining separate configuration files inside each microservice.
In Microservices Architecture:
- Multiple services exist
- Each service requires configuration
- Managing configurations separately becomes difficult
Centralized configuration solves this problem by storing all configurations in one centralized location.
Why Centralized Configuration is Important in Microservices
In large enterprise applications:
- Hundreds of microservices may exist
- Each service may have multiple environments
- Configuration changes happen frequently
Without centralized configuration:
- Configuration duplication increases
- Deployment complexity grows
- Managing secrets becomes difficult
- Configuration inconsistencies occur
Centralized configuration improves:
- Configuration management
- Scalability
- Security
- Maintainability
- Operational efficiency
Simple Banking Example
Suppose a banking platform contains:
- Payment Service
- Account Service
- Loan Service
- Notification Service
- Fraud Detection Service
All services require common configurations:
- Database URLs
- Kafka server details
- API keys
- JWT secrets
- Redis configuration
Without centralized configuration:
- Every service maintains separate config files
- Updating configurations becomes difficult
With centralized configuration:
- All services fetch configurations from central server
- Configuration management becomes easier
Without Centralized Configuration
Payment Service -> application.properties
Account Service -> application.properties
Loan Service -> application.properties
Notification Service -> application.properties
Configuration duplication occurs everywhere.
With Centralized Configuration
Config Server
|
------------------------------------------------
| | | |
Payment Account Loan Notification
Service Service Service Service
All services fetch configuration from one location.
How Centralized Configuration Works
Microservice Starts
|
Requests Configuration
|
Config Server Provides Configurations
|
Service Loads Properties
Main Components of Centralized Configuration
| Component | Purpose |
|---|---|
| Config Server | Stores and serves configurations |
| Config Repository | Stores configuration files |
| Microservices | Consume configurations |
Where Configurations are Stored
Centralized configurations are commonly stored in:
- Git repositories
- Database systems
- Cloud configuration services
- Vault systems
Git Repository Example
config-repo/
payment-service.yml
account-service.yml
loan-service.yml
application.yml
Config Server reads configurations from Git repository.
Real Banking Configuration Example
payment-service.yml
server:
port: 8081
spring:
datasource:
url: jdbc:mysql://bank-db/payment
jwt:
secret: banking-secret
account-service.yml Example
server:
port: 8082
spring:
datasource:
url: jdbc:mysql://bank-db/account
Why Environment Management is Important
Applications usually have multiple environments:
- Development
- Testing
- Staging
- Production
Each environment requires different configurations.
Environment Example
payment-service-dev.yml
payment-service-test.yml
payment-service-prod.yml
Banking Production Example
Development database:
jdbc:mysql://localhost/dev-db
Production database:
jdbc:mysql://prod-bank-db/payment
Spring Cloud Config Server
Spring Boot commonly implements centralized configuration using:
Spring Cloud Config Server
Spring Cloud Config Architecture
Git Repository
|
Spring Cloud Config Server
|
-----------------------------------------
| | | |
Payment Account Loan Notification
Service Service Service Service
Config Server Dependency
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-config-server
</artifactId>
</dependency>
Enable Config Server Example
@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {
}
Config Server Properties
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri:
https://github.com/bank/config-repo
Client Microservice Configuration
spring:
application:
name: payment-service
config:
import:
optional:configserver:http://localhost:8888
What Happens Internally?
Payment Service Starts
|
Calls Config Server
|
Fetches payment-service.yml
|
Loads Properties
Dynamic Configuration Refresh
One major advantage:
- Configurations can refresh without restarting services
Spring Refresh Example
@RefreshScope
@RestController
public class PaymentController {
}
Real Banking Example
Suppose:
- Payment API timeout changes from 5 seconds to 10 seconds
Update config repository:
timeout: 10s
Services refresh configuration dynamically.
Centralized Secret Management
Sensitive information:
- Passwords
- JWT secrets
- API keys
- Database credentials
can be managed securely.
Vault Integration Example
Common secret management tools:
- HashiCorp Vault
- AWS Secrets Manager
- Azure Key Vault
- Kubernetes Secrets
Why Centralized Configuration Improves Security
Without centralized management:
- Secrets may exist in multiple services
- Secret rotation becomes difficult
Centralized configuration:
- Reduces secret duplication
- Improves access control
- Simplifies credential rotation
Benefits of Centralized Configuration
- Centralized management
- Easy configuration updates
- Environment-specific configurations
- Improved security
- Reduced duplication
- Dynamic refresh support
Real Banking Use Cases
- Database configurations
- Kafka broker settings
- Payment gateway URLs
- Fraud engine endpoints
- JWT secret management
- Redis configuration
Cloud-Native Example
Kubernetes applications commonly use:
- ConfigMaps
- Secrets
for centralized configuration management.
Kubernetes ConfigMap Example
apiVersion: v1
kind: ConfigMap
metadata:
name: payment-config
data:
timeout: "5000"
Challenges of Centralized Configuration
- Single point of failure
- Config server availability issues
- Security risks if compromised
- Network dependency
Single Point of Failure Problem
If Config Server becomes unavailable:
- New services may fail to start
Therefore:
- High availability configuration is important
How High Availability is Achieved
- Multiple Config Server instances
- Load balancing
- Git repository replication
- Caching configurations locally
Best Practices for Centralized Configuration
- Store secrets securely
- Use environment-specific configs
- Enable config encryption
- Implement access control
- Use high availability config servers
- Monitor configuration changes
Centralized Configuration vs Local Configuration
| Feature | Centralized Configuration | Local Configuration |
|---|---|---|
| Management | Centralized | Distributed |
| Scalability | High | Limited |
| Security | Better | Harder to Manage |
| Configuration Updates | Easier | Complex |
Professional Interview Answer
Centralized Configuration in Microservices is a configuration management approach where all application configurations are stored and managed from a centralized server or repository instead of maintaining separate configuration files inside each service. It simplifies configuration management, improves security, supports dynamic configuration updates, and enables environment-specific configurations. Spring Cloud Config Server, Kubernetes ConfigMaps, and Vault systems are commonly used for centralized configuration management in banking systems, cloud-native applications, and enterprise microservices architectures.
Summary
Centralized Configuration is one of the most important operational patterns used in modern Microservices and Distributed Systems.
It helps manage configurations efficiently across multiple services and environments while improving scalability, security, and maintainability.
Banking systems, payment gateways, cloud-native platforms, e-commerce applications, and enterprise distributed systems heavily rely on centralized configuration for stable and manageable deployments.
Understanding centralized configuration is essential for backend developers, DevOps engineers, cloud architects, and microservices developers building scalable distributed applications.