How do you handle Configuration Management and Feature Flags?
Topic: microservices, Deployment. Level: Intermediate.
Answer
Externalize configuration from code (12-factor) so the same artifact runs in every environment. Use a central config service (Spring Cloud Config, Consul, k8s ConfigMaps) with per-environment overrides and, ideally, dynamic refresh without redeploy. **Feature flags** decouple deploy from release: ship code dark, then toggle features per environment/user cohort at runtime — enabling canary releases, A/B tests, and instant kill-switches. Keep secrets out of plain config (Q32) and audit flag changes.
```java
// Feature flag gates behavior at runtime — no redeploy to turn on/off
if (features.isEnabled("new-checkout", userId)) {
return newCheckoutFlow(cart); // gradually rolled out / A-B tested
}
return legacyCheckoutFlow(cart); // instant kill-switch back to this
```