Diagnosing a Sluggish Web UI and Handling a Live Defect
BehavioralModel answerLast updated
Explain how you would find and fix the cause of a slow web frontend, then how you would triage, contain, root-cause, communicate and safely ship a fix for a production bug.
You are asked two open-ended engineering questions. Answer both as you would in a technical screen, with a clear order of steps rather than a list of random techniques.
Scenario A: a slow frontend
Users report that a web application's frontend feels very slow. Walk through how you would:
- Narrow down and reproduce the problem.
- Identify the precise bottleneck, whether it is a particular asset, API call, component, or DOM element.
- Improve performance and confirm the improvement is real and lasting.
Scenario B: a bug in production
A defect has just been found in the live system. Describe how you would:
- Judge how serious it is.
- Limit the damage to users.
- Find the root cause.
- Keep stakeholders informed.
- Ship a fix with low risk.
- Reduce the chance of it happening again.
Be specific about tools, signals and trade-offs. Explain what you do first and why.
Hints
Hint 1
Start from measurement, not remedies: define what 'slow' means in numbers, decide which phase of the page lifecycle is slow (server, network, JS execution, rendering), and only then pick fixes.
Hint 2
For incidents, separate stopping the harm from understanding the cause. Think about which levers are fastest and safest (rollback, feature flag, rate limit) and what evidence you must preserve before using them.
Hint 3
Close both loops: verify the fix with the same measurements (or field data) you used to find the problem, and add a guard such as a performance budget, a regression test or an alert so it cannot silently return.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
What a strong answer shows
Both questions test judgment. A good answer follows a funnel from symptom to cause, measures before changing anything, protects users first during incidents, and ends with a prevention step. A weak answer is an unordered list such as "add caching, lazy load, use a CDN".
Scenario A: slow frontend
1. Scope and reproduce
Ask clarifying questions:
- Is it the first load, route changes, or a specific interaction (typing, scrolling, panning a large canvas)?
- Who is affected: all users or a segment (browser, device, region, network)? Since when? A sudden start suggests a recent deploy.
- What are the numbers? Use field data (RUM, Core Web Vitals): LCP above 2.5s is slow loading, INP above 200ms is sluggish interaction, and CLS indicates layout instability.
Then reproduce in a controlled setup: a clean profile with extensions off, CPU and network throttling in DevTools, and cold versus warm cache runs.
2. Locate the slow phase
| Phase | Where to look | Typical signals |
|---|---|---|
| Server | Network tab, backend traces | High TTFB, slow SSR or HTML |
| Assets | Waterfall, Lighthouse | Large bundles, unoptimized images, render-blocking CSS or fonts, missing compression or caching |
| API | Network tab, APM | One slow endpoint, sequential request chains, oversized payloads |
| JS execution | Performance panel | Long tasks over 50ms, slow parse, heavy hydration |
| Rendering | Performance panel, React Profiler | Excess re-renders, layout thrashing, huge DOM |
3. Pinpoint the culprit
- Asset: sort the waterfall by size and duration. Use a bundle analyzer to see which dependency bloats the bundle (for example a whole charting library on a landing page). The Coverage tab shows unused shipped JS.
- API: find the request that blocks first render, replay it in isolation, then follow the trace to the slow query, missing index or N+1 pattern.
- Component: record the interaction in the React Profiler and look for components with high render time or count. Check for unstable props or context churn.
- DOM element: in the Performance panel, look for long Layout and Recalculate Style blocks and forced synchronous layouts (reading
offsetHeightafter a write in a loop). Check DOM size withdocument.querySelectorAll('*').length. - Degradation over time: compare heap snapshots for detached nodes and leaked listeners.
4. Fix what was measured
- Bundles: route-level code splitting, dynamic
import(), tree shaking, lighter dependencies, deferring third-party scripts. - Assets: WebP or AVIF, responsive sizes, lazy loading, preloading the LCP image and key fonts, CDN with Brotli and long-lived hashed caching.
- APIs: parallelize independent calls, paginate, trim fields, fix indexes and N+1 queries, use HTTP caching or stale-while-revalidate, prefetch next-route data.
- Rendering: memoize only where the profiler shows cost, split contexts, virtualize long lists, batch DOM reads and writes, debounce input handlers.
- Heavy compute: move it to Web Workers. For drawing-heavy UIs, use canvas or WebGL rather than thousands of DOM or SVG nodes.
5. Verify and guard
Re-measure under identical conditions, then confirm in field data, since Lighthouse alone can mislead. Add performance budgets (bundle size, Lighthouse CI thresholds) and alerts on Web Vitals regressions.
Scenario B: production bug
1. Assess severity
Ask four things: blast radius (users, tenants, regions), impact type (data loss or corruption, security, money, blocked core flow, cosmetic), whether a workaround exists, and whether it is getting worse. Map this to a severity level. Outages, corruption and security problems are the highest severity: page people and declare an incident with a named incident commander so coordination does not compete with investigation. Minor issues go into the normal backlog.
2. Mitigate before root-causing
Use the least risky lever that restores service: roll back the deploy, switch off a feature flag, fail over, scale or rate-limit, or block the bad input path. If data is being corrupted, stop the writes first. Capture evidence (logs, heap dumps, affected record IDs) before restarting anything.
3. Find the root cause
- Correlate the start time with deploys, config changes, flags, dependency upgrades, migrations and traffic shifts.
- Use error tracking with release tags, structured logs keyed by trace ID, metrics and distributed traces.
- Reproduce in staging with realistic data and write a failing test.
- Narrow with
git bisector a release diff. - Keep asking why until you reach a process cause. "A null field crashed the parser" is a symptom. "No schema validation and no test fixture for that case" is the cause.
4. Communicate
Post updates on a fixed cadence (for example every 30 minutes) in an incident channel. Give support teams plain-language status: impact, workaround, ETA. Update the status page when customers are affected. Be honest about unknowns, and make sure stakeholders hear it from you first.
5. Deploy the fix safely
- Keep the change minimal and review it even under pressure.
- Merge with the failing test now passing.
- Roll out gradually (canary or percentage flag), watching error rates and key metrics, with a ready rollback.
- Backfill or repair any corrupted data with a tested, idempotent script.
6. Prevent recurrence
Hold a blameless postmortem within a few days: timeline, impact, root cause, what went well, and what did not. Produce owned, dated action items such as added tests, validation, alerts that would have detected it sooner, safer migrations, or better runbooks. Track them to completion.
Common mistakes
- Applying optimizations without profiling, or "fixing" Lighthouse scores while real users see no change.
- Memoizing everything in React, which adds cost without benefit.
- Debugging root cause while users are still being harmed.
- Restarting services and losing the evidence.
- Shipping the fix to 100% of traffic at once.
- Ending at "bug fixed" with no test, alert or process change.
Trade-offs to mention
Rollback is fast but may discard unrelated good changes. A feature flag is more surgical but requires prior setup. Aggressive lazy loading cuts initial load but can add request waterfalls and hurt interaction latency. Performance budgets catch regressions but can become noisy if set too tight.