Feature flags have become a staple of modern software delivery. Whether you’re interviewing for a junior backend role or a senior architecture position, you’ll likely be asked how you’ve used flags, why they matter, and how you keep them from turning into hidden technical debt.

What is a feature flag?

A feature flag (also called a toggle or switch) is a runtime configuration that enables or disables a code path. The key point is that the decision is made outside the compiled binary, so you can change behavior without rebuilding or redeploying.

Typical use cases

  • Canary rollout – expose a new feature to a small percentage of users first.
  • Kill‑switch – shut down a problematic feature instantly.
  • A/B testing – serve different variants to measure impact.
  • Technical debt – hide incomplete work while keeping the mainline clean.

How do you implement a flag?

Implementation varies by language, but the pattern is similar:

// Go example
var flags = map[string]bool{"newSearch": false}

func Search(q string) {
    if flags["newSearch"] {
        // new algorithm
    } else {
        // legacy algorithm
    }
}

Key considerations:

  • Centralized store – a service like LaunchDarkly, Unleash, or an internal config server.
  • Typed access – avoid stringly‑typed lookups; wrap flags in a struct.
  • Caching – pull values at start‑up or on change events to avoid per‑request latency.

When should you avoid a flag?

Flags are powerful but can become a maintenance nightmare if misused. Avoid them when:

  • The change is permanent and low‑risk – just merge the code.
  • The flag will remain true/false for months without a clear retirement plan.
  • The flag introduces complex branching that hurts readability.

Governance and lifecycle

A mature flag program includes:

PhaseOwnerTypical actions
CreationProduct/Engineering leadDocument purpose, default, rollout plan
ActivationRelease engineerEnable for target segment, monitor metrics
MonitoringSRE/Observability teamAlert on error spikes, latency changes
RetirementOwner of the flagRemove code, clean config, update docs

The goal is to keep the number of active flags low and to have a clear retirement date.

Performance considerations

A flag check is cheap, but the surrounding code can be costly if the flag gates heavyweight work. Mitigate this by:

  • Placing the flag check outside loops or hot paths.
  • Using lazy evaluation – only compute the new behavior when the flag is true.
  • Measuring overhead with profiling tools; most production systems see sub‑millisecond impact.

Sample interview Q&A

1. Basic: "What is a feature flag and why would you use one?"

Answer (45‑90 s): "A feature flag is a runtime switch that lets us turn a piece of functionality on or off without redeploying. It’s useful for rolling out changes gradually, rolling back quickly if something breaks, and running experiments. For example, in my last project we used a flag to enable a new recommendation engine for 5 % of users before a full launch, which let us catch a caching bug early." Typical follow‑up: "Can you describe the process you used to roll it out?"

2. Intermediate: "How do you ensure flags don’t become technical debt?"

Answer: "We treat flags like any other code artifact. Each flag gets a ticket that records its purpose, owner, and expiration date. Once the feature is stable, we schedule a cleanup sprint to remove the flag and the old code path. We also run a quarterly audit to flag any toggles that have been on for longer than the agreed window." Typical follow‑up: "What happens if a flag is left on by mistake after a rollout?"

3. Senior: "Explain your governance model for feature flags at scale."

Answer: "At scale we separate flag creation, activation, and retirement responsibilities. Product defines the business need and writes a brief; engineering builds a typed wrapper and adds it to our central config service. Release engineers handle the rollout, targeting a percentage of users and watching key metrics. Monitoring is hooked into our observability platform so any spike in error rate triggers an automatic rollback. Finally, the flag owner is responsible for retiring the flag within a predefined window, usually a few weeks after a successful rollout. This separation keeps ownership clear and prevents flags from lingering. "During a recent migration we had 120 active flags. By applying this model we reduced the number of stale flags by 40 % within two months and cut the incident rate related to flag misuse in half. "If a flag controls a critical path, we also add a circuit‑breaker guard that forces a safe default if the flag service becomes unavailable. "Overall, the model balances agility with accountability. "" Typical follow‑up: "How do you handle a situation where a flag causes a performance regression?"

Handling performance regressions

When a flag introduces latency, you should:

  1. Isolate – run a micro‑benchmark with the flag on/off.
  2. Profile – identify the hot spot (e.g., extra DB call, heavy serialization).
  3. Mitigate – add caching, lazy loading, or move the heavy work to a background job.
  4. Roll back – if mitigation takes too long, disable the flag until a fix is ready.

Using Call Assistant for practice

When you rehearse these answers, a tool like Call Assistant can listen to your spoken response, compare it to the template, and suggest refinements. It also keeps follow‑up questions on track, so you stay focused on the flag story that aligns with your resume.

How to practice this

  1. Record yourself answering each question aloud; aim for 45‑90 seconds per answer.
  2. Review the flag lifecycle checklist (creation → retirement) and map a real project from your resume onto it.
  3. Simulate a follow‑up by having a colleague ask the typical next question and iterate until the story flows naturally.

FAQ

  • Q: Can feature flags be used for database schema changes? A: Yes, but they should be combined with backward‑compatible migrations. The flag controls the new code path while the old schema remains functional.
  • Q: How do you test flag logic? A: Write unit tests for both branches and add integration tests that toggle the flag via the config service to verify end‑to‑end behavior.
  • Q: What’s the difference between a flag and a configuration value? A: A flag is binary (on/off) and usually drives code branching; a config value can be any type and often adjusts parameters without changing logic.
  • Q: Should every team have its own flag service? A: Centralizing flags reduces duplication and eases governance, but large organizations sometimes segment services by domain to limit blast radius.

Frequently asked questions

Can feature flags be used for database schema changes?

Yes, but they should be combined with backward‑compatible migrations. The flag controls the new code path while the old schema remains functional.

How do you test flag logic?

Write unit tests for both branches and add integration tests that toggle the flag via the config service to verify end‑to‑end behavior.

What’s the difference between a flag and a configuration value?

A flag is binary (on/off) and usually drives code branching; a config value can be any type and often adjusts parameters without changing logic.

Should every team have its own flag service?

Centralizing flags reduces duplication and eases governance, but large organizations sometimes segment services by domain to limit blast radius.

#concept questions#feature flags#interview prep#software engineering#devops