Skip to content
tezvyn:

Lifecycle of a feature flag experiment from creation to cleanup

Source: optimizely.comEasyHow cards are made

Lifecycle of a feature flag experiment from creation to cleanup

Tests operational rigor across the full flag lifecycle. A strong answer covers six stages: SDK instrumentation with event tracking, phased rollout, monitored experiment, ship/kill decision, and code cleanup.

What's really being asked

This question tests whether you understand that a feature flag is production infrastructure with a full lifecycle, not a one-time switch. For experimentation specifically, the interviewer wants to see that you know an experiment flag requires instrumentation, monitoring, a decision framework, and mandatory cleanup. Senior engineers are expected to prevent flag debt and treat rollout safety as a first-class concern.

The full answer

Stage one is implementation, where engineering responsibility is to instrument the feature behind a flag using an SDK decide method and add event tracking for the experiment metrics without requiring extra deploys. Stage two is configuration and QA, where the flag is off in production but enabled for internal environments or targeted test segments to validate behavior. Stage three is rollout, where the engineer sets percentage-based or canary exposure, monitors error rates and latency, and keeps a kill switch ready. Stage four is the experiment state, where traffic splits run against the defined metrics and the team avoids peeking until statistical significance is reached. Stage five is decision, where the team ships the winning variant, rolls back the loser, or iterates; engineering must then move the winning behavior to the default code path. Stage six is cleanup, where the flag is archived and the conditional branches and dead code are removed in a follow-up deploy.

The mistakes people make

Treating the flag as permanent configuration instead of temporary scaffolding. Failing to mention event tracking or success metrics, which turns the flag into a release toggle rather than an experiment. Leaving flags in the codebase after the experiment ends, which accumulates technical debt and makes the system harder to reason about. Ignoring rollback or kill switch procedures during rollout.

What usually comes next

How do you prevent flag sprawl in a large codebase? What is the difference between a feature flag and an experiment flag? How do you handle dependencies between multiple experiment flags? What metrics do you monitor before ramping from 1 percent to 100 percent?

A concrete example

Suppose you are testing a new checkout button color. You wrap the new component in a flag and instrument click events. You enable it for 5 percent of users in one region while watching conversion and error dashboards. After reaching significance you ship the winner, set the flag to 100 percent default, and schedule a ticket to remove the flag and old component code in the next sprint.

Interview question

After an experiment flag reaches statistical significance and the winning variant is chosen, what is the next engineering responsibility in a healthy lifecycle?

  • a.Keep the flag and both variants in the codebase but disable the loser to simplify future rollbacks
  • b.Archive the flag and delete the conditional branches before moving the winner to the default code path
  • c.Leave the flag at 100 percent rollout so the winning behavior remains active without requiring a new deploy
  • d.Move the winning behavior to the default code path and schedule cleanup of the flag and conditional branchesCorrect
Why?

The lifecycle requires engineering to move the winning behavior to the default code path after a decision, then archive the flag and remove dead code in a follow-up deploy. Leaving the flag at 100 percent or preserving dead code accumulates flag debt, and removing branches before moving the winner would delete the code you intend to ship.

Just read this? Test yourself on what you have been reading.

Read the original → optimizely.com

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles