📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

How do you use feature flags as an incident tool rather than just a release tool? Explain kill switches, gradual percentage rollouts and targeting, how you implement them in .NET with Microsoft.FeatureManagement and Azure App Configuration, how fast a change reaches running instances, and how you stop old flags from becoming a liability.

Covers feature flags for operations: kill switches and safe defaults, percentage and targeted rollouts, Microsoft.FeatureManagement with Azure App Configuration refresh, propagation delay, auditing flag changes, and flag clean-up and expiry.

Mid-Level Theory Intermediate azure-app-configuration feature-flags feature-management incident-response production progressive-delivery

🎯 Key points

  • Kill switch: an ops flag around a risky dependency or feature that turns it off without a deploy
  • Safe default: if the flag store is unreachable, fall back to the safe state (usually off); App Configuration replicas for resilience
  • Gradual rollout: targeting filter (1% → 10% → 50% → 100%) with telemetry tagged by flag state, judged against SLO metrics
  • Microsoft.FeatureManagement IFeatureManager.IsEnabledAsync / [FeatureGate] with App Configuration and a refresh interval (e.g. 30 s)
  • Know the propagation delay: refresh interval plus request-triggered refresh; IFeatureManagerSnapshot keeps one request consistent
  • Flag changes are production changes: audited, annotated on dashboards, linked from runbooks; related flags changed together via a snapshot or sentinel
  • Flag lifecycle: owner and expiry per release flag, removal tickets, stale-flag reports (Knight Capital 2012)

⏱ 30-second answer

A feature flag lets you change behaviour without a deploy, which makes it one of the fastest mitigations you have. A kill switch is a long-lived ops flag around a risky dependency or expensive feature: when it misbehaves you turn it off in seconds instead of rolling back. A gradual rollout uses percentage or targeting filters (1% → 10% → 50% → 100%) while you watch error and latency SLOs, so a bad change hurts a few users and is switched off, not rolled back.

In .NET I use Microsoft.FeatureManagement with Azure App Configuration, a refresh interval of about 30 seconds and a safe default if the store is unreachable. Flag changes are audited and annotated on dashboards. The trade-off is flag debt: every flag doubles code paths, so release flags get an owner and an expiry date.

🗣 Full answer (senior)

How I would answer this in an interview

"I separate flags by purpose, because they have different lifetimes. Release flags hide unfinished work and should live for weeks. Experiment flags split traffic for A/B tests. Ops flags, the kill switches, are long-lived on purpose: they wrap things that can hurt the system under stress, like a call to a recommendations service, an expensive report, or a new payment provider, so on-call can switch them off. In an incident, turning a flag off takes seconds and touches nothing else, whereas a rollback redeploys every change since the last release.

In .NET I use Microsoft.FeatureManagement backed by Azure App Configuration. Code asks IFeatureManager.IsEnabledAsync(\"Recommendations\"), or an endpoint has a [FeatureGate]. For rollouts I use the percentage or targeting filter, so 5% of users or one internal tenant get it first, and I watch the SLO dashboard before stepping up. Two details matter in an incident. First, propagation: with a 30-second refresh interval, a change can take up to that long, plus the next request, to reach every instance, so the runbook says 'wait one minute, then check the metric'. Second, the default: if App Configuration is unreachable at start-up or refresh, the app must fall back to the safe state, which for a kill switch usually means the feature is off. For example, at [company] we [wrapped the product recommendations call in a kill switch]; when [the recommendations service slowed to 8 seconds during a sale], on-call [turned it off and checkout p95 went from 9 s back to 300 ms within a minute], no deploy needed.

The mistake I see is never cleaning flags up. Every flag is a branch nobody tests both sides of. The famous case is Knight Capital in 2012, where a reused flag activated old dead code on one server and lost about 440 million US dollars in 45 minutes. So release flags get an owner, an expiry date and a removal ticket, and only ops flags are allowed to be permanent."


Kinds of flags

Kind Purpose Lifetime Who changes it
Release Ship dark, turn on when ready Days to weeks Team
Experiment A/B test, measure impact Weeks Product
Ops / kill switch Turn off a risky path under stress Permanent On-call
Permission Feature for a plan or tenant Long-lived Product / config

Flags vs other mitigations

Mitigation Speed Scope When it fits
Turn off a flag Seconds to a minute One feature The bad behaviour is behind a flag
Roll back the deployment Minutes Everything in the release Bad code with no flag
Scale out Minutes Capacity only Load, not a bug
Fail over region Minutes to hours Whole service Regional outage

What makes a good kill switch

Property Why
Wraps the call, not the UI only The load must actually stop
Has a working fallback (cached, empty, degraded) Off must not mean broken
Safe default when the store is down A config outage shouldn't enable risk
Named in the runbook with propagation time On-call knows it exists and how long to wait
Tested in both states The off path rots otherwise

Production example

During a sale, the recommendations API's p95 rose to 8 seconds and checkout p95 followed to 9 seconds. On-call turned off the Recommendations kill switch in App Configuration; within about 40 seconds all 12 instances had refreshed, checkout p95 was back to 300 ms, and the page showed popular products from a cached list instead.

🔍 What the interviewer is checking

Checks the candidate sees feature flags as an operational mitigation with real failure modes, not just a release convenience.

Green flags

  • Distinguishes ops kill switches from release and experiment flags
  • Explains safe defaults, fallbacks and propagation delay
  • Knows Microsoft.FeatureManagement and App Configuration refresh, or an equivalent
  • Has a plan for flag debt and auditing changes

Red flags

  • Thinks a flag flip is instant everywhere
  • Kill switch hides the UI but keeps calling the dependency
  • No plan to remove flags

📚 Learn in depth

1. How a flag is evaluated

 request ─► IFeatureManager.IsEnabledAsync("Recommendations")
                 │
                 ▼
       IConfiguration "feature_management" section  ◄── App Configuration provider (cached)
                 │                                          ▲
         filters? ── none ─► enabled / disabled              │ refresh every N s,
                 │                                          │ triggered by requests
                 ▼                                          │ (UseAzureAppConfiguration)
   Percentage / TimeWindow / Targeting filter ─► bool or variant

Microsoft.FeatureManagement reads flags from IConfiguration, so any configuration provider works. The Azure App Configuration provider caches values; the UseAzureAppConfiguration() middleware triggers a refresh in the background when a request arrives after the refresh interval has passed (in worker services you call IConfigurationRefresher.TryRefreshAsync yourself). Propagation delay is therefore refresh interval + time until the next request, per instance.

2. Filters and variants

  • Percentage: a random roll per evaluation; users can flip between on and off on each request unless you use targeting.
  • Targeting: deterministic by user id and groups (hash-based), so the same user stays in the same bucket. Needs an ITargetingContextAccessor.
  • TimeWindow: on between two times, useful for planned events.
  • Custom filters: implement IFeatureFilter, e.g. by tenant or region.

Version 4 of the library added variants through IVariantFeatureManager: a flag returns a named value (e.g. a timeout or an algorithm choice), useful for experiments and gradual configuration changes.

3. Telemetry: knowing who saw what

During a rollout or an incident you need to know which requests ran with the flag on. Two ways:

  • tag your own spans and metrics with the flag state (activity?.SetTag("feature.recommendations", enabled)), so dashboards can split error ratio and latency by cohort;
  • turn on the library's evaluation telemetry (in version 4, "telemetry": { "enabled": true } on the flag) and publish evaluation events to Application Insights, which App Configuration can then show per flag.

Without this, "did the new path cause the errors?" becomes guesswork.

4. Failure modes of the flag system itself

Failure Effect Defence
App Configuration unreachable at start-up App fails to start, or starts without flags optional: true with safe local defaults in appsettings; a start-up timeout
Store region outage Refresh fails everywhere Geo-replicas of the store (the provider can fail over to replicas automatically)
Unreachable at refresh Last known values stay in memory Fine; log and alert on repeated refresh failures
Someone flips the wrong flag Sudden behaviour change Audit log, RBAC, change annotations, two-person rule for sensitive flags
Two related flags changed one after the other Instances briefly see one changed and one not Change them together: a sentinel key that triggers one refresh, or an App Configuration snapshot
A request evaluates the same flag twice and gets different answers Half a request on the new path IFeatureManagerSnapshot (scoped) caches results for the request
Flag evaluated in a hot loop Extra allocations Evaluate once per request

5. Progressive delivery

A percentage rollout is a canary at the feature level. A typical schedule: internal users → 1% → 10% → 50% → 100%, each step held long enough to cover peak traffic and judged against the SLO (error ratio, p95 latency) of the affected endpoints, comparing the flag-on and flag-off cohorts from the telemetry above.

6. OpenFeature

OpenFeature is a CNCF vendor-neutral flag API with providers for many back ends. It's worth considering if you might switch vendors; Microsoft.FeatureManagement is the natural fit for an Azure-centric .NET shop.

7. The flag lifecycle

 created (owner, type, expiry) ─► rolling out ─► 100% on ─► code path removed ─► flag deleted from store
                                       │
                                       └─► rolled back ─► fix ─► roll out again
 ops flags: created ─► permanent, tested both ways each quarter, listed in the runbook

Every flag doubles the paths through a piece of code; ten independent flags is 1,024 combinations nobody tests. Controls: an owner and expiry per release flag, a report listing flags past expiry or unchanged for 90 days, removal in the definition of done, deleting the flag from the store only after the code no longer reads it, and never reusing a flag name for new behaviour.

Try it yourself

  1. Add Microsoft.FeatureManagement with App Configuration to an API, flip a flag in the portal, and time how long until each instance sees it.
  2. Stop network access to App Configuration and restart the app with optional: true; check which defaults apply.
  3. Use the targeting filter for 10% of users and confirm the same user always gets the same result.
  4. Tag request spans with the flag state and build a chart of error ratio split by cohort.
  5. Wrap a slow dependency in a kill switch with a cached fallback, then load test with the flag on and off.
  6. Write a small script that lists flags in App Configuration with their last-modified date and flags older than 90 days.

💻 Code

A kill switch around a slow dependency with a safe fallback, backed by Azure App Configuration with a 30-second refresh.

// Program.cs — packages: Microsoft.FeatureManagement.AspNetCore, Microsoft.Azure.AppConfiguration.AspNetCore, Azure.Identity
using Azure.Identity;
using Microsoft.FeatureManagement;

var builder = WebApplication.CreateBuilder(args);

builder.Configuration.AddAzureAppConfiguration(options =>
{
    options.Connect(new Uri(builder.Configuration["AppConfig:Endpoint"]!), new DefaultAzureCredential())
           .UseFeatureFlags(ff => ff.SetRefreshInterval(TimeSpan.FromSeconds(30))); // propagation budget for the runbook
}, optional: true); // store down at start-up => fall back to appsettings.json defaults below

builder.Services.AddAzureAppConfiguration();
builder.Services.AddFeatureManagement();
builder.Services.AddHttpClient<RecommendationsClient>(c => c.BaseAddress = new Uri("https://recs.internal/"));

var app = builder.Build();
app.UseAzureAppConfiguration(); // triggers refresh on requests after the interval

app.MapGet("/products/{id}/page", async (string id, RecommendationsClient recs, CancellationToken ct) =>
    Results.Ok(new ProductPage(id, await recs.GetAsync(id, ct))));

app.Run();

public static class Flags
{
    public const string Recommendations = "Recommendations"; // ops flag: permanent, owned by on-call, listed in the runbook
}

public sealed record ProductPage(string ProductId, IReadOnlyList<string> Recommended);

public sealed class RecommendationsClient(HttpClient http, IFeatureManager features, ILogger<RecommendationsClient> logger)
{
    private static readonly IReadOnlyList<string> Popular = ["sku-100", "sku-200", "sku-300"]; // degraded but useful fallback

    public async Task<IReadOnlyList<string>> GetAsync(string productId, CancellationToken ct)
    {
        if (!await features.IsEnabledAsync(Flags.Recommendations))
            return Popular; // kill switch off: no call at all, so the load on recs actually stops

        try
        {
            return await http.GetFromJsonAsync<List<string>>($"recommendations/{productId}", ct) ?? Popular;
        }
        catch (Exception ex) when (ex is HttpRequestException or TaskCanceledException)
        {
            logger.LogWarning(ex, "Recommendations failed for {ProductId}; serving fallback", productId);
            return Popular;
        }
    }
}
// appsettings.json: the safe defaults used when App Configuration is unreachable at start-up
{
  "feature_management": {
    "feature_flags": [
      { "id": "Recommendations", "enabled": false }
    ]
  }
}

⚠ Common mistakes

  • Mistake: Hiding only the UI behind the kill switch. Why it is wrong: the backend still calls the failing dependency, so the load and timeouts continue. Instead: gate the call itself and return a fallback.
  • Mistake: Defaulting to "on" when the flag store is unreachable. Why it is wrong: a configuration outage silently enables the risky path. Instead: local safe defaults and optional: true.
  • Mistake: Expecting a flag change to apply instantly. Why it is wrong: the provider caches for the refresh interval, and refresh is request-triggered. Instead: know the delay and write it into the runbook.
  • Mistake: Using the plain percentage filter for user-facing features. Why it is wrong: the same user flips between versions on each request. Instead: the targeting filter with a stable user id.
  • Mistake: Changing flags with no audit or annotation. Why it is wrong: responders can't see that a flag changed just before the incident. Instead: RBAC, App Configuration history, change events on dashboards.
  • Mistake: Never removing release flags. Why it is wrong: untested combinations and dead code accumulate; reused flags have caused real disasters. Instead: owner, expiry date and a removal ticket for every release flag.
  • Mistake: Testing only the "on" path. Why it is wrong: the fallback breaks unnoticed and the kill switch fails when you need it. Instead: tests for both states and occasional game-day flips.

🏛 Senior insight: trade-offs

Senior engineers design kill switches before the incident: every new external dependency or expensive feature gets the question "what do we turn off if this hurts us, and what does the user see then?" The answer goes into the code, the runbook and the dashboard. A flag nobody on call knows about is not a mitigation.

Option When it fits Cost When not to
Microsoft.FeatureManagement + App Configuration Azure-hosted .NET, moderate targeting needs Low; config store cost Complex experimentation analytics
Commercial flag platform (via OpenFeature) Many teams, experiments, streaming updates Licence cost, vendor Small team with simple flags
Config value in appsettings + redeploy Rare changes Free Incident mitigation (too slow)
Rollback No flag exists Minutes, all changes revert When a flag can isolate the fault

I measure flag hygiene like any debt: number of flags past expiry, flags with no owner, and how many incidents were mitigated by a flag versus a rollback.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate compares flags with rollbacks. Why: Checks they can choose between a flag flip, rollback, scaling and failover during an incident.
    How to answer

    Every minute of an outage costs customers, revenue and trust — for a busy checkout that can be thousands of dollars a minute — while the root cause can be found later from preserved telemetry. So responders ask "what changed?" and reach for the fastest, safest, reversible lever: roll back the release (an App Service slot swap or a previous container image), turn off the feature flag, scale out if it's genuinely capacity, fail over to Australia Southeast if a region is impaired, or shed load with rate limiting to protect the critical path.

    Good mitigation is rehearsed (a rollback you've never practised is a new risk), done one change at a time and verified against the SLIs. The trade-off is speed versus evidence: grab the evidence first when it costs seconds (a memory dump, a log export, a note of the deploy id), because a restart or rollback can destroy what explains the cause — but never delay mitigation by minutes to do it.

  2. When: Candidate mentions Azure App Configuration. Why: Checks they know App Configuration and Key Vault setup, refresh and managed identity in depth.
    How to answer

    I'd inventory and classify every setting first: secrets, environment-specific values, shared values, and which must change live. Secrets go to Key Vault. Non-secret settings and feature flags go to Azure App Configuration with a label per environment, and secrets are referenced from there through Key Vault references. The app authenticates with its managed identity using least-privilege roles, and where possible secrets disappear entirely through passwordless Entra ID auth to SQL, Storage and Service Bus.

    For refresh, use a sentinel key with a refresh interval and a secret refresh interval, and read live values through IOptionsMonitor. Rotation uses overlapping versions, so old and new both work during the window. Add start-up timeouts and replicas, and keep ValidateOnStart.

    The trade-off: central, audited, rotatable configuration, in exchange for a network dependency at start-up that you must design for.

  3. When: Candidate mentions gradual rollout or canary by percentage. Why: Checks they can define promotion criteria against SLOs rather than gut feel.
    How to answer

    Treat each step as a controlled experiment. Before starting, agree the promotion and rollback criteria: the SLIs for the affected endpoints (error ratio, p95 latency, one business metric such as checkout conversion), the thresholds and the minimum sample size. Use a targeting filter (hashed user id) so users stay in their cohort, and tag telemetry with the flag variant (an Application Insights custom dimension or OpenTelemetry attribute) so a KQL query or dashboard compares the new cohort against the control cohort in the same time window. Step 1% → 10% → 50% → 100%, holding each step through a peak period. If the treatment cohort is worse beyond the threshold, turn the flag off, automatically from an alert or by runbook. The trade-off: small steps are safe but need longer holds to gather enough traffic to be significant.

🛠 Real-world problems: how you handle them

Turning off recommendations to save checkout during a sale
Situation
An e-commerce .NET 10 API on [App Service / AKS] in Australia East, [12] instances, during a [Black Friday] sale at [~3,000] requests per second. The product page called an internal recommendations service synchronously.
Signals
Checkout p95 rose from [300 ms] to [9 s]; the SLO burn-rate alert paged; Application Insights dependency telemetry showed the recommendations call at p95 [8 s]; ThreadPool queue length climbing on all instances.
Investigation
Opened the service dashboard from the alert, split latency by dependency, and saw only the recommendations dependency had changed. Checked the runbook for the product page, which listed the `Recommendations` kill switch and its 30-second propagation. Confirmed no deploy in the last [24 hours].
Resolution
Immediate: turned off the `Recommendations` flag in App Configuration; within [~40 seconds] all instances served the cached popular list and checkout p95 returned to [300 ms]. Long term: the recommendations team fixed an [unindexed query]; we added a 500 ms timeout and circuit breaker to the call and re-enabled the flag with a 10% targeted rollout.
Prevention
Every new synchronous dependency now needs a kill switch with a fallback and a runbook entry; flag changes are annotated on dashboards automatically; a quarterly game day flips each kill switch in staging; release flags get an expiry date checked in CI.

How to tell it (STAR)

**S:** At [company], during a [big sale], checkout slowed from [300 ms] to [9 seconds] because a recommendations call on the product page was taking [8 seconds]. **T:** As [on-call / the senior on the team] I needed to stop the damage fast without a risky deployment at peak. **A:** The dashboard showed only that dependency had changed, and our runbook listed a kill switch for it, so I turned the flag off in App Configuration, waited the documented 30 seconds, and watched p95 fall back as instances refreshed. Afterwards I [pushed for / added] a timeout and circuit breaker on the call and made kill switches with fallbacks a requirement for new synchronous dependencies. **R:** Customer impact lasted [about 6 minutes] instead of the [30-plus] a rollback and redeploy would have taken, and we re-enabled recommendations safely with a 10% rollout [two days] later.

↩ Usually asked after

More in Production Tools

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me