← Workflows

阅读中文版本

CDN Cache Key Design

Diagnose and fix a performance bottleneck: profile the hot path, identify the dominant cost, and verify the improvement with a benchmark.

advanced~30 minperformanceprofilingoptimization

Objective

Reduce the p99 latency of the hot path by addressing the dominant cost with a verified benchmark.

Environment

  • A working performance environment with access to the target system and its tooling
  • Configuration and credentials for the performance workflow installed and verified
  • A rollback or undo path documented before any change is applied

Steps

1. Profile the hot path

Capture a CPU profile under representative load and identify the function that consumes the most time.

Expected state: A profile exists with the top cost centers ranked by self time.

2. Address the dominant cost

Optimize or cache the hottest function and confirm the change is covered by an existing or new test.

Expected state: The hot function is optimized and its test is green.

3. Verify with a benchmark

Run the before and after benchmark on the same machine and confirm the improvement is outside the noise band.

Expected state: The benchmark shows a statistically significant improvement.

Decision points

When should optimization stop?

  • When the hot path meets the budget
  • When no function is above 1 percent

Stop when the hot path meets the latency budget; further optimization has diminishing returns.

Expected outcome

Reduce the p99 latency of the hot path by addressing the dominant cost with a verified benchmark. The change is verified and a rollback path is confirmed.

Verification

Reduce the p99 latency of the hot path by addressing the dominant cost with a verified benchmark. Compare before and after metrics and confirm the expected state is reached.

Cleanup

Archive the run artifacts, remove temporary credentials, and update the runbook with any changes.

Overview

Diagnose and fix a performance bottleneck: profile the hot path, identify the dominant cost, and verify the improvement with a benchmark. The goal is to reduce the p99 latency of the hot path by addressing the dominant cost with a verified benchmark.

node --prof app.js && node --prof-process isolate-*.log > profile.txt

Steps

  1. Profile the hot path. Capture a CPU profile under representative load and identify the function that consumes the most time. Expected: A profile exists with the top cost centers ranked by self time.

  2. Address the dominant cost. Optimize or cache the hottest function and confirm the change is covered by an existing or new test. Expected: The hot function is optimized and its test is green.

  3. Verify with a benchmark. Run the before and after benchmark on the same machine and confirm the improvement is outside the noise band. Expected: The benchmark shows a statistically significant improvement.

Verification

Confirm the outcome by checking: reduce the p99 latency of the hot path by addressing the dominant cost with a verified benchmark. Run the verification command and compare the result against the expected state. If any check fails, stop and investigate before continuing.

Decision points

  • When should optimization stop?
    • When the hot path meets the budget
    • When no function is above 1 percent
    • Recommendation: Stop when the hot path meets the latency budget; further optimization has diminishing returns.