Spring Cloud Config Server Interview Questions and Answers
Master Spring Cloud Config Server with interview questions covering centralized configuration, Git backend, Config Client, encryption, refresh scope, Spring Cloud Bus, configuration hierarchy, and production best practices.
Spring Cloud Config Server Interview Questions and Answers
Introduction
In a microservices architecture, dozens or even hundreds of services require configuration such as:
- Database URLs
- API Keys
- Kafka Brokers
- Redis Hosts
- Feature Flags
- Logging Levels
- Third-party Endpoints
Managing these configurations separately for every service quickly becomes difficult.
Spring Cloud Config Server provides Centralized Configuration Management, allowing all services to retrieve their configuration from a single location.
Configuration is typically stored in:
- Git Repository
- Native File System
- Vault
- JDBC Database
- AWS S3 (custom)
- Kubernetes ConfigMaps (alternative approach)
Config Server Architecture
flowchart LR
GitRepository --> ConfigServer
ConfigServer --> CustomerService
ConfigServer --> PaymentService
ConfigServer --> LoanService
ConfigServer --> NotificationService
Q1. What is Spring Cloud Config Server?
Answer
Spring Cloud Config Server is a centralized configuration server that provides configuration properties to multiple Spring Boot microservices.
Instead of storing configuration inside each application,
all configuration is stored centrally.
Benefits
- Centralized management
- Version control
- Environment separation
- Dynamic refresh
- Easier deployments
Q2. Why do we need Config Server?
Without Config Server
Every service contains its own
- application.yml
- application.properties
Updating a common property requires redeploying every service.
Without Config Server
flowchart LR
CustomerService --> LocalConfig
PaymentService --> LocalConfig
LoanService --> LocalConfig
With Config Server
flowchart LR
GitRepository --> ConfigServer
ConfigServer --> CustomerService
ConfigServer --> PaymentService
ConfigServer --> LoanService
One configuration change can serve multiple services.
Q3. How does Config Server work?
Startup process
- Config Server starts.
- Connects to Git Repository.
- Reads configuration files.
- Config Client requests configuration.
- Config Server returns configuration.
- Application starts.
Request Flow
sequenceDiagram
Customer Service->>Config Server: Request Configuration
Config Server->>Git Repository: Read application.yml
Git Repository-->>Config Server: Configuration
Config Server-->>Customer Service: Properties
Customer Service->>ApplicationContext: Initialize Beans
Q4. Where are configuration files stored?
Most commonly,
configuration is stored in Git.
Example
config-repository
|
|-- application.yml
|-- customer-service.yml
|-- payment-service.yml
|-- application-prod.yml
|-- application-dev.yml
Benefits
- Version history
- Pull requests
- Rollback
- Auditing
- Team collaboration
Q5. How does Config Client connect to Config Server?
Dependency
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
</dependency>
Configuration
spring:
config:
import:
configserver:
http://localhost:8888
When the application starts,
it retrieves configuration from the Config Server.
Q6. How are environment-specific configurations managed?
Example
application.yml
application-dev.yml
application-test.yml
application-prod.yml
Client Request
/customer-service/prod
Response
Production-specific configuration.
Environment Flow
flowchart LR
Git --> application.yml
Git --> application-dev.yml
Git --> application-prod.yml
ConfigServer --> CustomerService
Q7. How does Configuration Refresh work?
Normally,
configuration changes require restarting the application.
Spring Cloud supports runtime refresh using
@RefreshScope- Spring Cloud Bus
Example
@RefreshScope
@RestController
public class ConfigController{
}
Refresh Endpoint
POST
/actuator/refresh
Q8. Can Config Server encrypt sensitive properties?
Yes.
Sensitive values such as passwords can be encrypted.
Example
{cipher}
AHSY782JSJ...
Config Server decrypts values before sending them to clients.
Alternative solutions
- HashiCorp Vault
- AWS Secrets Manager
- Azure Key Vault
Q9. What happens if Config Server is unavailable?
Possible approaches
- Fail Fast
- Retry
- Local Cache
- High Availability Config Servers
Configuration
spring:
cloud:
config:
fail-fast: true
Typical production setup
flowchart LR
GitRepository --> ConfigServer1
GitRepository --> ConfigServer2
ConfigServer1 --> Services
ConfigServer2 --> Services
Q10. Config Server Best Practices
Store Configuration in Git
Maintain version history.
Separate DEV/TEST/PROD
Use profile-specific configuration.
Encrypt Sensitive Values
Avoid plain-text passwords.
Enable Refresh
Use @RefreshScope where dynamic updates are required.
Secure Config Server
Protect it using OAuth2, JWT, or mTLS.
Banking Example
flowchart TD
GitRepository --> ConfigServer
ConfigServer --> CustomerService
ConfigServer --> PaymentService
ConfigServer --> LoanService
CustomerService --> PostgreSQL
PaymentService --> Kafka
LoanService --> MongoDB
Every service retrieves its configuration from a centralized source.
Common Interview Questions
- What is Config Server?
- Why use centralized configuration?
- How does Config Server work?
- What is Config Client?
- Where are configuration files stored?
- How does profile-based configuration work?
- What is
@RefreshScope? - How do you encrypt configuration?
- What happens if Config Server fails?
- Config Server best practices?
Quick Revision
| Topic | Summary |
|---|---|
| Config Server | Centralized configuration |
| Config Client | Retrieves configuration |
| Git | Most common backend |
| Profiles | Environment-specific configuration |
| @RefreshScope | Runtime configuration refresh |
| Spring Cloud Bus | Distributed refresh |
| Encryption | Secure sensitive properties |
| Fail Fast | Startup failure on config issues |
| Retry | Recover from temporary failures |
| High Availability | Multiple Config Server instances |
Config Retrieval Lifecycle
sequenceDiagram
Spring Boot App->>Config Server: Request Configuration
Config Server->>Git Repository: Read Config
Git Repository-->>Config Server: application-prod.yml
Config Server-->>Spring Boot App: Configuration
Spring Boot App->>ApplicationContext: Initialize Beans
ApplicationContext-->>Application: Ready
Production Example – Banking Platform
A banking platform consists of:
- Customer Service
- Account Service
- Payment Service
- Loan Service
- Notification Service
Configuration Strategy
- Configuration stored in a Git repository.
- Separate files for DEV, TEST, UAT, and PROD.
- Database credentials encrypted.
- Config Server deployed with two replicas behind a load balancer.
- Services fetch configuration during startup.
- Runtime configuration changes propagated using Spring Cloud Bus with Kafka.
flowchart LR
GitRepository --> ConfigServerCluster
ConfigServerCluster --> CustomerService
ConfigServerCluster --> PaymentService
ConfigServerCluster --> LoanService
ConfigServerCluster --> NotificationService
SpringCloudBus --> Kafka
Kafka --> CustomerService
Kafka --> PaymentService
Kafka --> LoanService
This architecture provides centralized configuration management, secure secret handling, high availability, and dynamic configuration updates across all microservices.
Key Takeaways
- Spring Cloud Config Server centralizes configuration for multiple microservices, eliminating duplicated configuration files.
- Configuration is typically stored in Git, providing version control, auditing, rollback capability, and collaborative management.
- Config Clients retrieve configuration during application startup using the Config Server.
- Environment-specific configuration is managed through profile-specific files such as application-dev.yml and application-prod.yml.
@RefreshScopeand Spring Cloud Bus enable runtime configuration updates without restarting services.- Sensitive properties should be encrypted or managed using dedicated secret management solutions such as Vault or AWS Secrets Manager.
- Production deployments should use multiple Config Server instances for high availability and resilience.
- Centralized configuration improves consistency, operational efficiency, and maintainability across enterprise Spring Cloud applications.