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

📚 Interview question

Tell me about a time p95 latency doubled after a release. How did you notice, how did you find the cause, what did you do in the first hour, and what did you change so a regression like that is caught before production next time?

A STAR story for a post-release latency regression: detection, deployment-marker correlation, rollback versus forward fix, root cause in code or query, and release guardrails.

Senior RealWorldScenario Advanced application-insights latency-regression performance real-world release-management star-story

🎯 Key points

  • Detected from a p95/p99 SLO burn-rate alert on version-tagged telemetry, not averages
  • Correlated with a deployment marker; ruled out config, traffic and data growth
  • Mitigated first: rollback or flag off in minutes, evidence captured before rollback
  • Weighed rollback risk: schema migrations and downstream contracts in the release
  • Narrowed with dependency breakdown (own code vs SQL vs HTTP) and proved with Query Store or dotnet-trace
  • Real fix plus a regression test that would have failed
  • Proactive guardrails: canary latency gate, per-version dashboards, cost and DTU alerts
  • Result in numbers: p95 before/during/after, minutes to mitigate, regressions caught later

⏱ 30-second answer

I tell it as detect → mitigate → diagnose → fix → prevent. The p95 alert fired [N] minutes after a release; the deployment marker in Application Insights lined up exactly, so I rolled back first (slot swap back, [X] minutes) instead of debugging live. Then I used the dependency breakdown to see where the extra time went: own code, SQL or a downstream call. In my case it was [an EF Core query whose plan changed / an N+1 / a sync call]. I proved it with [Query Store / dotnet-trace], fixed it, and added a latency gate on canary traffic plus [a query-count test]. Result: p95 back from [X] to [Y] ms. The trade-off I mention: rolling back fast costs you the live evidence, so capture a trace or dump before you roll back if it takes under five minutes.

🗣 Full answer (senior)

How I would answer this in an interview

"At [company] we ran [the orders API], about [N] requests per second with a p95 SLO of [300 ms]. Twenty minutes after a Tuesday release the burn-rate alert fired: p95 had gone from [250] to [520] ms with no errors. The deployment marker in Application Insights sat exactly on the step change, so my first decision was to mitigate, not investigate. I grabbed a 60-second dotnet-trace from one instance, then swapped the staging slot back. p95 recovered within [four] minutes.

With the pressure off, I compared the old and new versions in Application Insights. The dependency view showed SQL time per request had tripled, while our own code time was flat. Query Store showed one query, the order-summary lookup, with a new plan: a refactor had moved a filter after a ToList(), so EF Core was pulling [40,000] rows and filtering in memory. I moved the filter back into the IQueryable, checked the generated SQL with ToQueryString(), and re-released behind a feature flag to [10%] of traffic first.

The bigger change was the guardrail. I added an integration test that asserts the SQL command count and row count for that endpoint, and we added an automatic canary gate: if canary p95 is more than [20%] above baseline for ten minutes, the pipeline stops. In the next [six] months it caught [two] regressions before customers saw them. What I learnt is that latency regressions are a release-process problem as much as a code problem."


The shape of a strong answer

Step What you say Evidence that makes it senior
Detect Which alert, which percentile p95/p99 SLO burn rate, not average or CPU
Correlate What changed Deployment marker, config change, traffic mix, data growth
Mitigate Rollback, flag off, scale out Minutes to mitigate; evidence captured first
Diagnose Where the time went Dependency breakdown, Query Store, dotnet-trace flame graph
Fix Root cause, not symptom Diff of the change; generated SQL; benchmark
Prevent Why it won't recur Test, canary gate, analyser, checklist

Usual causes of a post-release latency regression

Cause Signal Tool that proves it
EF Core query change (client evaluation, N+1, missing AsNoTracking) SQL dependency time up, command count up Application Insights dependencies, ToQueryString(), Query Store
New synchronous or blocking call Thread count climbing, ThreadPool queue length up dotnet-counters (threadpool-queue-length)
New downstream HTTP call in the hot path New dependency appears in the end-to-end trace Transaction search, Application map
Allocation-heavy code Gen 0/1 GC rate and % time in GC up dotnet-counters, dotnet-trace GC events
Config change (lower pool size, log level Debug) Specific to one setting Diff of app settings; release notes
Cache key change causing misses Cache hit ratio drops, DB load up Custom metric, Redis INFO stats

When not to roll back

Rolling back is the default, but not when the release contained a non-reversible schema migration, or when the regression is minor and the release fixes a security issue. Then you mitigate forward: scale out, disable the feature flag, or hotfix.

Production example

The template: p95 on [the orders API] went from [250] to [520] ms after release [x.y]; rolled back in [4] minutes; root cause was [in-memory filtering after ToList(), 40,000 rows per call]; fix cut SQL time per request from [180] to [12] ms; the canary gate later caught [2] more regressions before full rollout.

🔍 What the interviewer is checking

Checks whether you handle a production regression with calm, evidence-based judgement and leave the system better, and whether you can tell it clearly with your own contribution and a measured result.

Green flags

  • Mitigates first, with evidence captured before rollback
  • Names the percentile, the SLO and the tool used at each step
  • Explains the mechanism of the slowdown, not just "the query was slow"
  • Adds a guardrail that would have caught it, and has numbers for the outcome

Red flags

  • Long live debugging while customers suffer
  • "We" throughout, no personal actions
  • No result, or numbers that collapse under a follow-up
  • Blames a colleague or another team

📚 Learn in depth

1. What the interviewer is really assessing

A latency-regression story tests four things at once: operational judgement (do you mitigate before you investigate), diagnostic method (do you narrow with data or guess), technical depth (can you name the mechanism that made it slow) and ownership after the fix (did the system get better, or did you just patch it). The question is asked to almost every senior .NET candidate because nearly everyone has lived through one, so a vague answer stands out.

2. The diagnostic funnel

Alert: p95 up 2x
   |
   v
What changed? -- deployment marker / config / traffic / data growth
   |
   v
Where is the time? -- Application Insights: server time = own code + dependencies
   |            \
   v             v
Own code         Dependency (SQL / HTTP / Redis)
 dotnet-counters  Query Store, plan diff,
 dotnet-trace     dependency duration by target
   |             |
   v             v
Root cause --> fix --> test that would have failed --> release guardrail

The key move is splitting server time into own code and dependencies. Application Insights records each SQL and HTTP call as a dependency, so a query in KQL that sums dependency duration per request, before and after the release, tells you in two minutes which half to look at.

requests
| where timestamp > ago(6h) and name == "GET /orders/{id}"
| summarize p95 = percentile(duration, 95) by bin(timestamp, 5m), application_Version

3. Why percentiles, not averages

A regression that affects 10% of requests (for example, only large customers with many orders) barely moves the average but doubles p95 or p99. That is why the story should name the percentile and the SLO. If you say "the average went up a bit", the interviewer hears that you weren't watching the right number.

4. Mitigate before you diagnose, but capture evidence

Rollback destroys the live state. If you can capture evidence in under five minutes, do it first: a 30–60 second dotnet-trace collect --profile cpu-sampling, or a snapshot from the Application Insights Profiler. Then roll back. Saying this out loud is a strong senior signal, because it shows you balance customer impact against learning.

5. Frameworks for telling it

  • STAR (Situation, Task, Action, Result) is the default. Keep S and T to 20 seconds, spend 60% on A, and end R with a number.
  • CAR (Context, Action, Result) is tighter for a 60-second version.
  • SOAR (Situation, Obstacle, Action, Result) works when the interesting part is a blocker, for example the rollback was not possible because of a migration.

6. How the answer is scored

Interviewers commonly score on a 1–4 scale per competency: 1 = vague or team-only ("we fixed it"); 2 = clear actions but no evidence; 3 = clear personal actions, evidence, a number; 4 = all of that plus a systemic change and a reflection. Most candidates stop at the fix; the guardrail and the reflection move you to a 4.

7. Reusing the story

The same incident answers: "Tell me about a production incident", "a time you used data to make a decision", "a time you improved a process" (lead with the canary gate), and "a time you made a mistake" (if the regression was your change). Prepare one paragraph per angle.

Try it yourself

  1. Write the KQL query above for one of your own services and find the p95 per application version for the last week.
  2. Run dotnet-counters monitor -p <pid> --counters System.Runtime while load-testing a debug build and note the ThreadPool queue length and GC rate at baseline.
  3. Take a 30-second dotnet-trace and open it in PerfView or Visual Studio to find the hottest method.
  4. Write your own story in the STAR template in the code tab and time yourself: it should be 90–120 seconds.
  5. Write the three alternative openings (incident, data-driven decision, process improvement) for the same story.

💻 Code

The key fix in this example: a filter moved after materialisation, and the test that now guards it.

namespace Orders.Api.Queries;

public sealed record OrderSummary(int Id, string Status, decimal Total);

public sealed class OrderSummaryQuery(OrdersDbContext db)
{
    // Before (the regression): ToListAsync() ran first, so EF Core pulled every row
    // for the customer and the Status filter ran in memory.
    // var all = await db.Orders.Where(o => o.CustomerId == customerId).ToListAsync(ct);
    // return all.Where(o => o.Status != "Archived").Select(...).ToList();

    // After: the whole filter and projection stay in the IQueryable, so SQL does the work.
    public Task<List<OrderSummary>> GetAsync(int customerId, CancellationToken ct) =>
        db.Orders
            .AsNoTracking()
            .Where(o => o.CustomerId == customerId && o.Status != "Archived")
            .OrderByDescending(o => o.CreatedAt)
            .Take(50)
            .Select(o => new OrderSummary(o.Id, o.Status, o.Total))
            .ToListAsync(ct);
}
STAR template (fill in your own details)
S: At [company], [service] handled [N req/s] with a p95 SLO of [X ms].
T: After release [version], p95 doubled to [Y ms]; I was [on call / the release owner].
A: I [captured a trace], [rolled back in N min], used [App Insights dependencies / Query Store]
   to find [root cause], fixed it by [change], and added [test + canary gate].
R: p95 back to [X ms]; mitigation in [N min]; gate caught [N] regressions in [period].

Illustrative only (not a real history):
S: Orders API, 400 req/s, p95 SLO 300 ms. T: p95 hit 520 ms after a release; I was on call.
A: Trace, slot swap back in 4 min, Query Store showed a new plan pulling 40k rows; moved the filter into SQL.
R: SQL time per request 180 ms -> 12 ms; canary gate caught 2 later regressions.

⚠ Common mistakes

  • Mistake: Starting with ten sentences of system background. Why it is wrong: The interviewer loses the thread before the incident even starts. Instead: One sentence of context with scale and SLO, then the alert.
  • Mistake: Saying "we" throughout. Why it is wrong: The interviewer can't score what you personally did. Instead: Use "I" for your actions and name the team's part briefly.
  • Mistake: Debugging live for an hour before rolling back. Why it is wrong: It shows you value the puzzle over customers. Instead: Capture quick evidence, mitigate, then diagnose.
  • Mistake: Rolling back without checking what else shipped. Why it is wrong: If the release ran a destructive migration, changed a message contract or a downstream integration already depends on the new behaviour, the old code can fail harder than the slow new code. Instead: Say you checked the release for migrations and contract changes, and chose flag-off or a forward fix when rollback wasn't safe.
  • Mistake: Scaling out as the "fix". Why it is wrong: Extra instances or a bigger Azure SQL tier hide the regression and keep costing money every hour. Instead: Use scale-out only to buy time, and say what it cost.
  • Mistake: Quoting average latency or CPU. Why it is wrong: Averages hide tail regressions and CPU is a cause, not a symptom. Instead: Quote p95/p99 against an SLO.
  • Mistake: Ending at "and we fixed the query". Why it is wrong: No result, no prevention, no learning. Instead: Give before/after numbers and the guardrail you added.
  • Mistake: Blaming the developer who made the change. Why it is wrong: Signals a blame culture. Instead: Talk about the gap in the process that let it through.
  • Mistake: Inventing precise numbers you can't defend, or drowning a non-technical interviewer in KQL. Why it is wrong: Follow-ups expose the first; the second loses the listener. Instead: Real, rounded numbers and one technical detail per step.

🏛 Senior insight: trade-offs

What makes this sound senior is scope and system thinking: you protected customers first, you used evidence to narrow the cause, and you changed the release process so the class of problem is caught automatically. Mention the trade-off you made (rollback lost evidence, so you took a trace first) and what it cost. If you can quantify the guardrail's value later ("caught two regressions in six months"), that is the strongest line in the answer.

Proactive monitoring is the other half. Seniors don't wait for a customer to complain: they have SLO burn-rate alerts on p95/p99, telemetry tagged by application version so the comparison is instant, and dashboards that show dependency time per request. In the cloud, a latency regression is also a cost event: more instances autoscale in, Azure SQL DTU or vCore usage climbs, and the bill moves. Mention that you watched (or added an alert on) database utilisation and autoscale count, because it shows you think about the platform, not just the code.

Mitigation When it fits Cost When not to
Roll back / slot swap Stateless change, quick to revert Lose live evidence; feature delayed Irreversible migration or changed contract in the release
Feature flag off Change was flagged Needs flag discipline in advance Change wasn't behind a flag
Scale out Load-related, buys time Money every hour; may hide the cause Bottleneck is the database
Hotfix forward Rollback impossible, cause obvious Risk of a second bad release Cause not yet proven
Guardrail Catches Effort
Canary with latency gate Most regressions under real traffic Medium (pipeline + metrics)
Version-tagged SLO dashboards and burn-rate alerts Regressions within minutes of rollout Low once telemetry is tagged
Query-count / SQL snapshot tests EF Core query regressions Low
BenchmarkDotNet in CI Hot-path CPU/allocation regressions Medium; noisy without dedicated agents

🔗 Follow-ups the interviewer may ask

  1. When: Candidate says the cause was an EF Core query or a SQL plan change. Why: Checks the technical drill-down from Application Insights to the execution plan and the LINQ change.
    How to answer

    First I confirm it's the release: Application Insights with the deployment annotation, comparing p95 by operation before and after. Then I check where the time goes: in the slow operation, are SQL dependencies longer (a worse query) or more numerous (N+1)? Next, Query Store on Azure SQL: Regressed Queries and Top Resource Consuming Queries show which statement got worse and whether its plan changed. I map that SQL back to code with TagWith comments (or the text), then read the LINQ diff: typical culprits are a non-sargable predicate, a new collection Include, a lost projection, or a parameter type change. I mitigate first: roll back or flag the change off; force the old plan only if it's purely a plan regression. Then fix the LINQ, verify the plan, and add query tags, a perf test and Query Store alerts. The trade-off: rollback is fastest, but only the root cause stops it recurring.

  2. When: Candidate says they weren't sure whether the slowness was in their code or a dependency. Why: Checks whether they can split latency between own code and dependencies with traces and counters.
    How to answer

    I split the request into time in my code and time in dependencies. In Application Insights, the end-to-end transaction view and a KQL query comparing request duration with the sum of its dependency durations tell me quickly: if one dependency's p95 jumped at 10 am, it's them; if dependencies are normal but requests are slow, the time is in my process. A gap before a dependency call starts means queueing inside my service: ThreadPool starvation, an exhausted connection pool or a rate limiter. dotnet-counters confirms CPU, GC and queue lengths. For a slow dependency I contain it with per-attempt timeouts, a circuit breaker, a bulkhead and a fallback; for my own code I roll back or scale while I fix it. The trade-off: aggressive timeouts protect you but turn slowness into errors, so they need fallbacks.

  3. When: Candidate mentions adding a canary or release gate as prevention. Why: Checks that the prevention is concrete and they know how it works, not just a buzzword.
    How to answer

    Ship the new version alongside the old and send it a small share of traffic (5–10%) using App Service deployment slot traffic routing, Container Apps revision weights or gateway weights (Front Door, APIM, YARP). Tag telemetry with the version (application_Version / service.version) so Application Insights can compare canary and stable p95 and error rate over the same window. A pipeline stage (Azure DevOps gate or a GitHub Actions job running a KQL query, or an Azure Monitor alert) waits [10–30 minutes]; if canary p95 is more than [20%] above stable or errors exceed the SLO, it sets the weight back to 0 automatically, otherwise it steps up (10% → 50% → 100%). Keep risky features behind feature flags (Azure App Configuration) so you can turn one off without redeploying. Size the canary so it gets enough requests for a meaningful comparison.

🛠 Real-world problems: how you handle them

p95 doubles after a release because a filter moved after ToList()
Situation
[The orders API] on [Azure App Service, 4 instances], about [400] req/s at peak, p95 SLO [300 ms]. A routine Tuesday release [version x.y] included a refactor of the order-summary query. I was [on call / the release owner].
Signals
SLO burn-rate alert 20 minutes after the slot swap: p95 from [250] to [520] ms, p99 over [1.5] s. No errors. Azure SQL DTU/CPU up from [35%] to [70%]. The Application Insights deployment marker sat exactly on the step change. A few customer reports of a slow order screen from [large accounts].
Investigation
Captured a 60-second `dotnet-trace` from one instance before rolling back. After rollback, compared versions in Application Insights: server time split showed SQL dependency time per request tripled while own-code time was flat, ruling out GC, ThreadPool starvation (dotnet-counters queue length normal) and the new HTTP client. Ruled out a data-growth or statistics problem because the change was a step at the release, not gradual. Query Store showed the order-summary query's logical reads up ~[50x]. The release diff showed `ToListAsync()` moved before the `Status` filter, so EF Core fetched all of a customer's orders and filtered in memory; `ToQueryString()` confirmed the missing WHERE clause.
Resolution
Mitigation: swapped the slot back within [4] minutes; p95 recovered immediately. Real fix: moved the filter and projection back into the IQueryable with `AsNoTracking()` and `Take(50)`, verified the SQL, and re-released behind a feature flag to [10%] of traffic, then 100% after an hour of clean metrics.
Prevention
An integration test asserting the SQL command count and that the generated SQL contains the filter; a code-review checklist item on materialisation before filtering; a canary stage with an automatic gate (canary p95 > baseline + 20% for 10 minutes fails the pipeline); a dashboard of p95 per application version.

How to tell it (STAR)

**S:** At [company] I worked on [the orders API], about [400] requests a second with a 300 ms p95 SLO. **T:** Twenty minutes after a release I was [on call] when p95 doubled to [520] ms, mostly hurting our [largest customers]. **A:** I took a quick trace, then swapped the slot back so customers recovered in [four] minutes. Using Application Insights I saw SQL time per request had tripled while our code was flat, and Query Store pointed at one query: a refactor had moved a filter after `ToList()`, so we were pulling [40,000] rows per call. I fixed it, re-released to [10%] of traffic first, and added a SQL-count test and an automatic canary latency gate. **R:** SQL time per request dropped from [180] to [12] ms, and over the next [six] months the gate stopped [two] regressions before customers saw them.

More in Production Incidents

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me