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

📚 Interview question

During an incident, why do you mitigate before you know the root cause? Which mitigations would you reach for first in a .NET service on Azure — rollback, feature flags, scaling, failover, shedding load — and how do you choose between them and avoid making things worse?

Covers the mitigate-first principle, the main mitigation levers (deployment rollback and slot swap, feature flag kill switches, scaling out, regional failover, load shedding and rate limiting), how to choose a lever from 'what changed', and the risks of each.

Mid-Level Theory Intermediate failover feature-flags incident-response mitigation observability rollback

🎯 Key points

  • Outage minutes cost revenue and trust (often thousands of dollars a minute at peak); root cause can be found later from preserved evidence
  • First question: what changed? (deploy, config, flag, traffic, dependency)
  • Rollback or slot swap for a bad release; must be rehearsed and fast (minutes)
  • Feature flag kill switch with Microsoft.FeatureManagement / Azure App Configuration
  • Scale out only for genuine capacity problems; it can amplify a failing dependency
  • Regional failover (Australia East to Southeast) when a region or zone is impaired
  • Load shedding / rate limiting protects the core journey
  • Capture evidence (dump, logs) when it takes seconds; one change at a time, verified with SLIs

⏱ 30-second 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.

🗣 Full answer (senior)

How I would answer this in an interview

"The reason to mitigate first is simple economics: customers are paying for every minute, and the root cause doesn't get any less findable if I restore service — as long as I keep the evidence. So the first question I ask is 'what changed?' Most incidents follow a change: a deploy, a configuration or feature-flag change, a traffic spike, or a dependency going bad. The answer points to the lever.

If a release went out in the last hour, I roll it back — on App Service that's swapping the staging slot back, on AKS it's kubectl rollout undo or redeploying the previous image tag. If the change was a new feature behind a flag, I turn the flag off in Azure App Configuration, which takes effect in seconds without a deploy. If it's real capacity — CPU saturated, thread-pool queue growing with traffic — I scale out. If Australia East is impaired, I fail over to Southeast with Front Door or Traffic Manager. And if a dependency is drowning, I shed load: rate-limit the non-critical endpoints so checkout keeps working.

For example, at [company] a release introduced an N+1 query on the orders page; p95 went from [200 ms] to [4 s]. We swapped the slot back in [3] minutes, and only then pulled the query from Application Insights to find the cause. The mistake I see is scaling out as a reflex: if the database is the bottleneck, ten more app instances just send ten times more queries at it. Mitigation is about picking the lever that matches the change — and changing one thing at a time so you know what worked."


Mitigation levers

Lever Use when Time to effect Risk
Rollback / slot swap A deploy correlates with the start 1–5 min Schema changes that aren't backward-compatible
Feature flag off A flagged feature is involved Seconds (after config refresh) Flag not covering the whole change
Config revert A setting changed Minutes Secrets and config caches
Scale out / up Genuine saturation from traffic Minutes (instances warm up) Amplifies load on a failing dependency
Restart instances Leak or stuck state, no recent change Minutes Destroys evidence; problem returns
Regional failover Region or zone impaired Minutes (DNS/Front Door) Data replication lag, capacity in the secondary
Load shedding / rate limit Overload threatens everything Seconds to minutes Some users get 429/503
Block bad traffic Abuse, bot, a single bad client Minutes (WAF rule) Blocking legitimate users

Choosing: what changed?

Signal Likely lever
Started within minutes of a deploy Rollback
Started when a flag/config changed Revert flag/config
Traffic doubled, resources saturated Scale out, shed load
Dependency errors (SQL, Redis, third party) Circuit breaker, degrade feature, fail over the dependency
One region's health checks failing Regional failover
No change, slow memory growth Capture a dump, then restart, then investigate

Safety rules

  1. Capture evidence when it's cheap: dotnet-dump collect or an App Service memory dump before restarting a leaking instance.
  2. One change at a time, announced in the incident channel with a timestamp.
  3. Verify with the SLI, not with 'it looks fine on my machine'.
  4. Rehearse rollbacks and failovers; an untested failover is a second incident.
  5. Expand/contract migrations so the previous build can still run against the new schema — otherwise rollback isn't possible.

Production example

A pricing service started returning 500s 4 minutes after a deploy. The slot swap back took 90 seconds and the error rate fell from 12% to 0.2%. The cause — a renamed configuration key — was found afterwards from the preserved logs, and ValidateOnStart was added so the next bad config fails in the staging slot instead.

🔍 What the interviewer is checking

Checks that the candidate prioritises customer recovery, knows the practical mitigation levers on Azure, and has the judgement to pick the right one safely.

Green flags

  • Starts from 'what changed?'
  • Names concrete levers: slot swap, kubectl rollout undo, App Configuration flags, Front Door failover, rate limiting
  • Warns that scaling can amplify a dependency failure
  • Captures evidence before restarting
  • Mentions backward-compatible schema changes for rollback

Red flags

  • "I'd find the bug and hotfix it" as the first move
  • Restarts everything immediately with no evidence captured
  • Several changes at once with no verification

📚 Learn in depth

1. The cost asymmetry

cost of outage   = minutes x (users affected x value per minute)
cost of mitigation = small, reversible change + some evidence risk

Root cause analysis benefits from calm and complete data; mitigation benefits from speed. Doing them in that order is cheaper than doing them together.

2. 'What changed?' as the first query

Most production incidents are triggered by change. Make changes visible in one place: deployment annotations on dashboards, App Configuration revision history, feature flag audit logs, and Azure Activity Log for infrastructure.

// Azure resource changes in the hour before impact
AzureActivity
| where TimeGenerated between (datetime(2026-11-20 00:30) .. datetime(2026-11-20 01:30))
| where OperationNameValue has_any ("write", "swap", "restart")
| project TimeGenerated, Caller, OperationNameValue, ResourceGroup, _ResourceId
| order by TimeGenerated asc

3. Rollback mechanics on Azure

          before swap                after swap
production slot: v42 (new, bad)    production slot: v41 (old, good)
staging slot:    v41 (old, good)   staging slot:    v42

A swap just re-points hostnames after warming the target, so swapping back is fast — provided the old build is still in the staging slot. On AKS, Deployments keep revisionHistoryLimit ReplicaSets so kubectl rollout undo can go back.

The trap is the database: if v42 ran a migration that dropped or renamed a column, v41 breaks. The expand/contract pattern keeps every schema change compatible with the previous build.

4. Feature flags as kill switches

Microsoft.FeatureManagement reads flags from configuration; with Azure App Configuration and a refresh interval (for example 30 seconds) a flag change reaches every instance without a deploy. A kill switch should default to the safe path and be tested in both states.

5. Why scaling can make it worse

4 instances x 50 DB connections = 200 -> DB at 100% CPU
scale to 12   x 50 DB connections = 600 -> DB connection limit, timeouts everywhere

Scale out only when the bottleneck is the app tier itself. If a dependency is the bottleneck, reduce load on it: circuit breakers, caching, load shedding.

6. Load shedding in ASP.NET Core

The built-in rate limiter (AddRateLimiter) can reject excess requests with 429 on non-critical endpoints, keeping capacity for the checkout path. Concurrency limiters cap in-flight work so latency stays bounded instead of the whole service collapsing.

7. Failover

Active-passive across Australia East and Southeast needs data replication (Azure SQL failover groups, geo-redundant storage), warm capacity in the secondary, and a rehearsed procedure. Failover with replication lag can lose recent writes — that is a business decision, so it should be agreed before the incident.

Try it yourself

  1. Deploy two builds to an App Service with a staging slot and time a swap and a swap back.
  2. Put a feature behind a flag in Azure App Configuration with a 30-second refresh, and measure how long a flag change takes to reach all instances.
  3. Add a fixed-window rate limiter to a non-critical endpoint and load-test it with k6 to see 429s while the critical endpoint stays fast.
  4. Run dotnet-dump collect -p <pid> on a local app and practise analysing it with dotnet-dump analyze before you need it.
  5. Write the KQL above for your subscription and check which changes happened in the last day.

💻 Code

A kill switch and load shedding in ASP.NET Core. The flag is read from Azure App Configuration so on-call can turn the feature off in seconds; the rate limiter keeps non-critical traffic from starving checkout.

// Program.cs
using Azure.Identity;
using Microsoft.AspNetCore.RateLimiting;
using Microsoft.FeatureManagement;

var builder = WebApplication.CreateBuilder(args);

// Flags and config come from Azure App Configuration and refresh every 30 seconds,
// so a kill switch takes effect without a deploy.
builder.Configuration.AddAzureAppConfiguration(options =>
    options.Connect(new Uri(builder.Configuration["AppConfig:Endpoint"]!), new DefaultAzureCredential())
           .UseFeatureFlags(flags => flags.SetRefreshInterval(TimeSpan.FromSeconds(30))));
builder.Services.AddAzureAppConfiguration();
builder.Services.AddFeatureManagement();

// Load shedding: cap the non-critical endpoints, never the checkout path.
builder.Services.AddRateLimiter(options =>
{
    options.RejectionStatusCode = StatusCodes.Status429TooManyRequests;
    options.AddConcurrencyLimiter("non-critical", o =>
    {
        o.PermitLimit = 50;
        o.QueueLimit = 0; // reject immediately instead of queueing and growing latency
    });
});

var app = builder.Build();
app.UseAzureAppConfiguration(); // triggers the config/flag refresh on requests
app.UseRateLimiter();

app.MapGet("/recommendations/{customerId}", async (string customerId, IFeatureManager features) =>
{
    // Kill switch: when off, return a safe default instead of calling the slow recommender.
    if (!await features.IsEnabledAsync("Recommendations"))
        return Results.Ok(Array.Empty<string>());

    return Results.Ok(new[] { "sku-1", "sku-2" }); // real call omitted
}).RequireRateLimiting("non-critical");

app.MapPost("/checkout", () => Results.Accepted()); // no limiter: protected path

app.Run();

Rollback commands on-call should have in the runbook:

# App Service: swap production back to the previous build in staging
az webapp deployment slot swap --resource-group rg-shop --name app-orders --slot staging --target-slot production

# AKS: roll back to the previous ReplicaSet and watch it finish
kubectl rollout undo deployment/orders-api -n shop
kubectl rollout status deployment/orders-api -n shop

# Capture evidence before restarting a leaking .NET process
dotnet-dump collect -p 1 -o /tmp/orders-api.dmp

⚠ Common mistakes

  • Mistake: Investigating the root cause while customers are still failing. Why it is wrong: Every minute of investigation is a minute of outage. Instead: Mitigate on the best hypothesis about what changed, then investigate.
  • Mistake: Scaling out as a reflex. Why it is wrong: If a dependency is the bottleneck, more instances multiply the load on it. Instead: Check where saturation is before scaling.
  • Mistake: Restarting instances before capturing evidence. Why it is wrong: The memory dump or in-process state that explains the cause is gone. Instead: Take a dump of one instance, then restart.
  • Mistake: Making several changes at once. Why it is wrong: You don't know which one helped, or which one hurt. Instead: One change, announced with a timestamp, verified with the SLI.
  • Mistake: A rollback that has never been rehearsed. Why it is wrong: It fails under pressure, or the schema is no longer compatible. Instead: Practise rollbacks and use expand/contract migrations.
  • Mistake: Treating mitigation as the end. Why it is wrong: The flag stays off forever and the cause comes back. Instead: Track every temporary mitigation as a ticket in the postmortem.
  • Mistake: Failing over without understanding replication lag. Why it is wrong: Recent writes can be lost. Instead: Agree RPO and failover authority before an incident.

🏛 Senior insight: trade-offs

The senior skill is preparing mitigations before incidents: every release can be rolled back in minutes, risky features ship behind flags, critical paths have load-shedding and degradation modes, and failover is rehearsed. In the incident itself the skill is restraint — one reversible change at a time, chosen from evidence about what changed.

Beyond one incident, a senior engineer builds the culture that makes this normal: a 'mitigation readiness' item in the definition of done (how do we turn this off or roll it back?), game days where the team practises failover and rollback on a schedule, and postmortem actions that shorten time to mitigate rather than only fixing the specific bug. Over a year that shows up as a falling time-to-mitigate trend.

Lever When it fits Cost to have ready When not to use it
Rollback Recent deploy correlated with impact Slots/image history, backward-compatible schema Change can't be undone (data migrated destructively)
Feature flag New or risky behaviour Flag plumbing, testing both paths Old flags left in code for years
Scale out App tier is the saturated resource Autoscale rules, quota Dependency is the bottleneck
Failover Region/zone failure Paired-region capacity, replication Small, local faults; replication lag unacceptable
Load shedding Overload threatens the core journey Rate limiter policies, priorities Normal traffic patterns (hides capacity issues)

Measure it with time to mitigate per incident: if most incidents take more than 15 minutes to mitigate, invest in faster rollback and flags before anything else.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions feature flags or Azure App Configuration. Why: Checks how flags and configuration are managed and refreshed in production.
    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.

  2. When: Candidate says 'just roll back'. Why: Checks whether the candidate knows schema changes can block a rollback and how expand/contract avoids it.
    How to answer

    Zero downtime means every migration must be compatible with the app version that is already running, because during a rolling deploy or slot swap the old and new code share one database. The pattern is expand/contract: first expand (add nullable columns, new tables, new indexes online), deploy code that writes both shapes, backfill in batches, switch reads, and only in a later release contract (drop the old column or table).

    • A rename becomes add + dual-write + backfill + drop, never RenameColumn in one step.
    • A NOT NULL column is added nullable or with a default, backfilled, then tightened.
    • Destructive changes ship one release after the code stops using them.

    The trade-off: three or four small releases instead of one, in exchange for no outage and an easy rollback at every step.

  3. When: Candidate mentions checking what changed or reading dashboards. Why: Checks whether the candidate can find the signal quickly during an incident.
    How to answer

    An incident dashboard must answer three questions in the first screen: are users hurting, since when, and where. So the top row is SLO status and error budget, then RED for the service (rate, 5xx ratio, p50/p95/p99) with the SLO threshold drawn on the panels. The next row is RED for each dependency (database, downstream APIs, queues) so you can see where the fault starts. Below that, USE panels for the runtime, pods and database, collapsed by default.

    Every time series carries deploy and feature-flag annotations, because most incidents follow a change, and panels link to traces and logs filtered to the same service and time window. One template as code with service and region variables serves every service.

    The trade-off: fewer panels make it faster to read, but you need drill-down paths for the detail you removed.

🛠 Real-world problems: how you handle them

Reflex scale-out turned a slow database into a full outage
Situation
An [orders API] on AKS, [8] pods, backed by Azure SQL [S3]. At a [Black Friday] traffic peak, p95 latency rose from [250 ms] to [3 s]. The first responder scaled the deployment to [24] pods.
Signals
After the scale-out, Azure SQL showed connection count near its limit and `Timeout expired` / pool exhaustion exceptions spiked in Application Insights; the error rate went from 1% to 30%. CPU on the pods was low throughout.
Investigation
dotnet-counters on one pod showed low CPU but a growing ThreadPool queue waiting on SQL. Azure SQL Query Performance Insight and Query Store showed one query with a regressed plan consuming most CPU. Pod CPU being low ruled out app-tier capacity.
Resolution
Immediate: scaled back to 8 pods, turned off the non-critical 'order history' feature flag that ran the heavy query, and rate-limited the reporting endpoint. Then forced the last known good plan in Query Store. Long term: fixed the query and index, and added a connection-count panel to the dashboard.
Prevention
Runbook step 'check where saturation is before scaling'; autoscale rules capped by the database's capacity; Query Store automatic plan correction enabled; load test before peak events.

How to tell it (STAR)

**S:** At [company], during [a sales peak] our orders API slowed to [3 s] p95, and the first response was to triple the pods. **T:** I [joined as the incident lead / was the second responder] and had to stop the errors climbing. **A:** I checked dotnet-counters and saw pod CPU was low but threads were waiting on SQL, so I scaled back down, turned off the order-history flag that ran the heavy query, and forced the previous plan in Query Store. **R:** Errors dropped from [30%] to under [1%] within [10] minutes, and we capped autoscaling by database capacity and added a 'where is the saturation?' step to the runbook.

↩ Usually asked after

More in Incident Response

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me