Interview Prep Zoneby CuriouserLabs

Question 3 of 5 · staff level

Design a profiles strategy for dev → staging → prod. What belongs in a profile, and what doesn't?

🎤 Say this first

Keep profiles few and boring: a base application.yml with safe defaults, one thin file per environment for shape differences (pool sizes, log levels, feature URLs), and secrets/endpoints injected by the platform — never in files. Profiles are also good for capability toggles (local-stubs, seed-data) — but resist profile explosion (dev-john-kafka2): combinatorial contexts nobody can reason about. Cardinal rules: same artifact everywhere; prod-parity for staging; profile-specific beans only for genuinely different infrastructure (stub vs real adapter); and never encode business logic in if (profile == …).

The full picture

  • What varies per environment: connection sizes, timeouts, log levels, external system URLs, feature flags' defaults. What must not: schema, business rules, serialization formats, security posture (staging with auth off is a fake staging).
  • Profile beans, sparingly: @Profile("local") on a stub PaymentPort beats if-statements; but if you have profile-conditional beans everywhere, you've built N applications sharing a repo.
  • Profile groups (spring.profiles.group.prod=prod,metrics,audit) compose capabilities without teams memorizing sets.
  • Guardrails: fail startup if no explicit profile in server environments (a naked java -jar should not quietly run 'default'); assert prod profile + prod DB URL agreement with a startup check — config drift between what-you-think-runs and what-runs is an incident class.
  • Local dev: docker-compose / Testcontainers-backed local profile so 'runs on my machine' is the same Postgres/Kafka as prod — profile strategy and dev-experience strategy are the same document.

🔄 Likely follow-up questions

  • How do profiles interact with @ActiveProfiles in tests, and how do you test the prod wiring shape?
  • Feature flags vs profiles — where's the boundary?
  • How would you detect config drift between staging and prod automatically?