Overview
Spring Cloud Config allows you to update configuration at runtime without restarting services. This is critical for making quick changes to feature flags, connection strings, or operational parameters.Configuration refresh is supported when services have the
spring-boot-starter-actuator and @RefreshScope annotations on beans that consume configuration properties.Refresh Strategies
There are two main approaches to refreshing configuration:Individual Service Refresh
Call
/actuator/refresh on each service that needs updated configuration.Broadcast Refresh (Spring Cloud Bus)
Trigger a single refresh that propagates to all services via message bus.
Individual Service Refresh
Using the /actuator/refresh Endpoint
The refresh endpoint must be explicitly exposed in your configuration:Refresh Workflow
Update Configuration in Git
Make changes to the YAML files in the
sgivu-config-repo and commit them:Refresh Config Server (if needed)
The Config Server automatically detects Git changes, but you can force a refresh:Or if using
/actuator/refresh on the Config Server itself:Refresh the Microservice
Trigger a refresh on the service that needs the updated configuration:The response shows which configuration keys were updated:
Refreshing Multiple Services
If you updated shared configuration that affects multiple services, refresh each one:Spring Cloud Bus for Broadcast Refresh
Overview
Spring Cloud Bus uses a message broker (RabbitMQ or Kafka) to broadcast refresh events to all services simultaneously.Setting Up Spring Cloud Bus
With Spring Cloud Bus, you only need to call one endpoint to refresh all connected services.
What Can Be Refreshed?
Refreshable Configuration
Beans annotated with@RefreshScope can be reloaded:
- Feature flags
- Timeouts and retry settings
- API endpoint URLs
- Logging levels (with some limitations)
- Rate limiting thresholds
- Caching TTL values
Non-Refreshable Configuration
- Server port (
server.port) - Eureka instance configuration (hostname, instance ID)
- Database connection pools (URL, username, password)
- OAuth2 client registration (client ID, secret, scopes)
- JWT keystore settings (location, passwords)
- Spring Session store type (Redis vs JDBC)
When to Use Refresh vs Restart
Use Refresh For
Feature Toggles
Enable or disable features without downtime.
Operational Tuning
Adjust timeouts, retries, or rate limits.
URL Changes
Update downstream service URLs.
Log Levels
Increase logging detail for debugging.
Requires Restart
Security Changes
OAuth2 configuration, keystore paths, credentials.
Database Settings
Connection strings, pool sizes, drivers.
Server Configuration
Port numbers, SSL settings, context paths.
Discovery Changes
Eureka client settings, instance metadata.
Step-by-Step Refresh Guide
Scenario: Update Zipkin Sampling Rate
Let’s walk through updating the distributed tracing sampling rate from 10% to 50%:Refresh in Production
Best Practices
Test First
Always test configuration changes in dev before production.
Rolling Refresh
Refresh one instance at a time in multi-instance deployments.
Monitor Impact
Watch metrics and logs after refresh to catch issues early.
Document Changes
Record what was changed and why in commit messages.
Security Considerations
Limitations and Considerations
Refresh Limitations
- Beans must be
@RefreshScope- Only annotated beans are reloaded - State is lost - In-memory state in refreshed beans is reset
- No atomic updates - Each service refreshes independently
- Connection pools persist - Database/Redis connections aren’t recreated
- Scheduled tasks continue -
@Scheduledmethods use old config until next execution
When Things Go Wrong
Refresh returns empty array
Refresh returns empty array
Cause: No configuration actually changed, or the properties aren’t in
@RefreshScope beans.Solution: Verify the property path is correct and that beans consuming it are annotated.Service behavior doesn't change
Service behavior doesn't change
Cause: Configuration is cached or used at startup only.Solution: Check if the property requires a restart. Consider using
@RefreshScope on relevant beans.Refresh endpoint returns 404
Refresh endpoint returns 404
Cause: Endpoint is not exposed in
management.endpoints.web.exposure.include.Solution: Add refresh to the include list and restart the service once.Config Server doesn't see Git changes
Config Server doesn't see Git changes
Cause: Config Server may be caching or hasn’t pulled latest commits.Solution: Restart Config Server or configure webhook-based refresh.
Automating Refresh with Git Webhooks
For advanced setups, configure Git webhooks to automatically trigger refresh when config changes:This requires the
spring-cloud-config-monitor dependency and a message bus (RabbitMQ/Kafka).Related Resources
Monitoring
Monitor services after configuration refresh
Validation
Validate configuration before refresh
Security
Secure refresh endpoints in production
Testing Changes
Test configuration changes locally