Skip to main content

How to: Identify Hot Paths & Bottlenecks

[!TIP] A "Hot Path" is code that runs frequently or is critical for user experience. Optimizing here yields high ROI. Optimizing elsewhere is often a waste of time.

This guide outlines the standard procedures for identifying Hot Paths in WepNG using our available tooling.

1. Using Application Insights (Production/Staging)

Application Insights is our primary source of truth for real-world performance.

Procedure

  1. Navigate: Azure Portal -> WepNG Resource -> Performance blade.
  2. Sort: Sort the "Operation Name" list by Duration (95th percentile) to find slow requests, AND by Count to find high-frequency requests.
  3. Identify:
    • High Count + Low Duration: Check for cumulative CPU usage. (e.g., a 10ms request called 1M times/hour).
    • High Duration: These are latency bottlenecks (e.g., ExportPDF).
  4. Drill Down: Click Samples -> Select a slow request -> View End-to-End Transaction Details.
    • Look for Long Dependencies (SQL queries, HTTP calls).
    • Look for "Gaps" in the timeline (CPU heavy processing in C#).

2. Using MiniProfiler (Development)

MiniProfiler is active in the Staging and Dev environments (bottom-right corner overlay).

Procedure

  1. Interact: Perform the action in the browser (e.g., "Load Student Profile").
  2. Inspect: Click the specific interaction in the MiniProfiler overlay.
  3. Analyze:
    • N+1 Queries: Look for valid SQL queries marked as DUPLICATE or a long list of identical SELECTs.
    • Slow SQL: Queries taking > 500ms are highlighted in red.
    • Controller Time: If "Controller" time is high but "SQL" is low, you have a CPU Hot Path (e.g., looping in C#, generating PDFs).

3. Using Visual Studio Diagnostic Tools (Local)

When you can reproduce the slowness locally.

Procedure

  1. Start Debugging: F5 in Visual Studio.
  2. Open Diagnostics: Debug -> Windows -> Show Diagnostic Tools.
  3. Record CPU Profile:
    • Select CPU Usage tab.
    • Click Record CPU Profile.
    • Perform the action in the browser.
    • Stop Recording.
  4. Analyze Call Tree:
    • Switch to Call Tree view.
    • Expand the "Hot Path" (marked with flame icons 🔥).
    • This shows exactly which C# method (e.g., String.Concat, DataFeeder.Calculate) is consuming the most CPU cycles.

4. Common WepNG Hot Paths (Known)

ComponentSymptomTool to Verify
FinancialTransactionImporterXML Parsing loopVS CPU Profiler
WayTDFeederLoop calculating turnoverApplication Insights (Duration)
HomeController.SolveFeeTitleN+1 Query on LangsMiniProfiler (Duplicate SQL)
WepEmailGeneratorSMTP BlockingApp Insights (Dependency Duration)