Quick revision
The short answer
We build one artifact per service and run the same artifact in development, staging and production, with every difference coming from external configuration. Defaults live in the jar, environment-specific overrides come from environment variables, Kubernetes ConfigMaps or a config server, and secrets come from a secrets manager, never from files in the repository. Each service validates its configuration at startup with @Validated @ConfigurationProperties, and configuration changes are reviewed and audited like code.
What to remember
In this answer, we designed configuration for 100 services across three environments. One artifact runs everywhere; defaults live in the jar and the platform starter; environment overrides come from environment variables, ConfigMaps or a config server through one mechanism for all services; secrets come from a secrets manager and only references sit in Git. Every service validates its settings at startup with @Validated @ConfigurationProperties, and configuration changes are reviewed, rolled out and audited like code.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
We build one artifact per service and run the same artifact in development, staging and production, with every difference coming from external configuration. Defaults live in the jar, environment-specific overrides come from environment variables, Kubernetes ConfigMaps or a config server, and secrets come from a secrets manager, never from files in the repository. Each service validates its configuration at startup with @Validated @ConfigurationProperties, and configuration changes are reviewed and audited like code.
Why this question is asked
With 100 services and three environments, there are 300 combinations of configuration, and every one of them can break production. The problems are familiar: staging works but production does not because the build was different, a password sits in a Git history, or a typo in one value takes a service down at night. Interviewers ask this design question to see whether we can set a few clear rules that scale, rather than pick a tool. In this answer, we will recap the principle of one artifact, design the layers of configuration, decide where secrets live, add validation at startup, and make configuration changes go through the same review as code.
1A Quick Recap of Externalised Configuration
Externalised configuration means the code does not decide which environment it runs in; the environment tells the code. Spring Boot is built for this: its Environment combines many property sources, such as files in the jar, files next to it, environment variables and imported locations, and the more specific sources override the more general ones. So a single jar can read a database URL from application.yml on a laptop and from an environment variable in production without any rebuild.
The first rule of the design follows directly: build once, deploy everywhere. The container image that passed tests in staging is, byte for byte, the image that runs in production. If production needs a different build, we are shipping something nobody tested.
2Designing the Layers
We give each kind of setting one home, ordered from most general to most specific. Each layer has a clear owner, which matters as much as the order.
- Command-line or one-off overridesrare, for incident work, logged
- Secrets from the secrets managerpasswords, keys, tokens; injected at runtime
- Environment overridesenv variables, ConfigMaps or config server, per environment
- Shared platform defaultscompany starter: timeouts, observability, security
- Service defaults in the jar
application.ymlwith safe values for every environment
5 layers, from the top down. Step through them one at a time.
Developers own the bottom layers in code; the platform and operations own the environment and secret layers.
The jar's application.yml holds every property the service understands with a safe default, so a developer can run it locally with almost no setup. The platform's shared starter supplies company-wide defaults such as tracing and connection pool limits, so 100 services do not each repeat them. Environment overrides hold only what really differs: URLs, sizes, feature switches. Keeping that layer small is the point; if a staging override file has 200 lines, most of them belong in defaults.
3Choosing Between Environment Variables, ConfigMaps and a Config Server
On Kubernetes, the simplest mechanism is a ConfigMap per service and environment, exposed as environment variables or as a mounted application.yml that Spring Boot can import with spring.config.import. It is visible, versioned with the deployment manifests in Git, and needs no extra infrastructure. A central config server, such as Spring Cloud Config, adds shared files across services and change notification, at the cost of another critical service that must be up for anything to start.
For most companies I would start with manifests in Git, rendered per environment by the deployment tooling, and add a config server only for a clear need such as many services sharing the same values. Whichever we choose, it should be one mechanism for all 100 services, so that an engineer debugging any service knows where to look.
4Where Secrets Live
Secrets get a layer of their own because their rules are different: they must not be readable by everyone who can read configuration, they must be rotated, and access to them must be audited. They live in a secrets manager, such as HashiCorp Vault or a cloud provider's secret store, and reach the service at runtime, either injected as environment variables or files by the platform or fetched by the application through a config import. The repository holds only references to them. A secret committed to Git is compromised even after deletion, because the history keeps it, so a pre-commit or pipeline secret scanner is part of the design, not an extra.
5Validating at Startup
The cheapest moment to catch a bad value is when the new version starts, before it receives traffic. Each service binds its settings to @ConfigurationProperties classes annotated with @Validated, with constraints on every value that has limits. A missing URL or a pool size of 5000 then stops the new pods from becoming ready, and the rollout halts with the old pods still serving.
6Treating Configuration Changes Like Code
Configuration causes as many incidents as code, so it gets the same process. Changes are made by pull request against the deployment repository, reviewed by someone who knows the service, and applied by the pipeline, never by hand with kubectl edit. The pipeline keeps a record of who changed what and when, which is also the audit trail regulators ask for. Changes roll out the same way as code, starting with one environment, so a bad value is found in staging, and rolling back means reverting a commit.
Finally, we make the effective configuration visible: a startup log line listing active profiles and the source of key settings, and a secured configprops endpoint. When something goes wrong at 3 a.m., the first question is what the service is actually running with, and the answer should take seconds.
7Follow-up questions
Should we use profiles named dev, staging and prod?
Sparingly. A single profile per environment that only activates the matching overrides is fine, but beans that behave differently per environment are a warning sign, because production then runs code paths staging never exercised. Values belong in external configuration; profiles are for real behaviour differences, such as a fake email sender locally.
How do we handle a configuration change that must take effect without a restart?
Most settings should not need that; a rolling restart is cheap and safe in Kubernetes. For values that really change at runtime, such as feature switches or rate limits, a feature flag service is the better tool, because it has targeting, gradual rollout and an audit log built in.
How do we stop 100 services from drifting apart?
A shared platform starter with company defaults, a template for new services, and a periodic report of each service's overrides. If many services override the same default to the same value, the default is wrong and should change in the starter.
8Conclusion
In this answer, we designed configuration for 100 services across three environments. One artifact runs everywhere; defaults live in the jar and the platform starter; environment overrides come from environment variables, ConfigMaps or a config server through one mechanism for all services; secrets come from a secrets manager and only references sit in Git. Every service validates its settings at startup with @Validated @ConfigurationProperties, and configuration changes are reviewed, rolled out and audited like code.
Open with
The core rule is build once, deploy everywhere: each service produces one image, and the image that passed staging is exactly what runs in production. Everything that differs comes from external configuration, which Spring Boot supports through its ordered property sources.
Then, if they want more
I would define layers with clear owners. The jar's application.yml holds every property with a safe default, so a developer can run it locally. A shared platform starter supplies company defaults like timeouts and observability.
Environment overrides, ideally a small set, come from one mechanism for all services, for example ConfigMaps or environment variables rendered from a deployment repository, or a config server if we have a real need for shared values.
Secrets are a separate layer from a secrets manager like Vault, injected at runtime, rotated and audited; the repository only has references, and a secret scanner runs in the pipeline. Each service binds settings to Validated ConfigurationProperties with constraints, so a bad value stops the new pods from becoming ready and the rollout halts while old pods keep serving.
And configuration changes go through pull requests, review and the pipeline, never manual edits, rolled out environment by environment with revert as rollback. Finally, I make effective configuration visible through a startup log and a secured configprops endpoint.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Framework reference, Core technologies
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Design how configuration should be managed for 100 services across development, staging...": https://scrivio-interview-library.netlify.app/spring-boot/spring-configuration/719825c95d/