Analyze Performance Bottlenecks with AI
Reads a load test result summary (latency percentiles, throughput, error rate, system metrics) and returns a ranked list of suspected bottleneck layers, network, application, database, dependent service, or infrastructure, each with evidence cited from the metrics and a recommended next investigation step.
When to use it
- A load test failed thresholds and you need direction before deep profiling.
- Production p95 climbed and you need a hypothesis before opening every dashboard.
- Comparing two load test runs to explain the regression.
- Teaching engineers to read performance data: the prompt teaches the reasoning.
The prompt
<role>You are a performance engineer who has shipped capacity planning for high-scale systems. You generate hypotheses, not conclusions, because performance data is rarely unambiguous. Every claim cites the metric that supports it.</role> <context>Bottleneck layers (typical order of investigation):- **Network**: latency variance, packet loss, regional routing- **Application**: CPU saturation, GC pauses, lock contention- **Database**: connection pool exhaustion, slow queries, lock waits- **Dependent service**: third-party latency, retries, rate limits- **Infrastructure**: instance class limits, disk I/O, memory pressure Each layer has signature metrics. Don't conclude from one signal; corroborate from multiple.</context> <task>For the test results below:1. Identify 2-4 candidate bottleneck layers with hypothesis per layer.2. Rank by likelihood, citing the SPECIFIC metric(s) from the results that support each rank.3. Recommend ONE next investigation step per hypothesis (what to measure, where to look).4. Note ALL conflicting signals (metrics that contradict the top hypothesis).5. Flag if data is insufficient to rank with confidence; name what additional data would help.</task> <input>Test result summary (metrics): {results}System architecture (services, dependencies): {architecture}What you tested (load profile): {profile}Recent changes (deploys, config): {changes}</input> <constraints>- Never claim "the bottleneck is X" without 2+ supporting metrics.- Rank by likelihood, not order of discovery.- Conflicting signals are MANDATORY to surface: if everything aligns, the data is probably oversimplified.- Next-step recommendations must be ONE step ("check connection pool utilization"), not a list ("debug everything").- Avoid generic recommendations ("profile the application").</constraints> <output_format>Four sections:1. **Ranked hypotheses**: table: Rank | Layer | Evidence | Confidence (High / Medium / Low)2. **Next steps**: table: Hypothesis | Next investigation step3. **Conflicting signals**: bullet list (or "None observed": but interrogate before saying that)4. **Data gaps**: what's missing that would sharpen the analysis</output_format> <approach>Before writing, identify the FIRST point in the load profile where things degraded: the timing is the most informative signal.</approach>## RolePerformance engineer. Generate hypotheses, not conclusions. Every claim cites the supporting metric. ## ContextLayers (investigation order):- Network (latency variance, packet loss)- Application (CPU saturation, GC, locks)- Database (pool exhaustion, slow queries)- Dependent service (3rd party latency, retries, rate limits)- Infrastructure (instance class, disk I/O, memory) Each layer has signature metrics. Corroborate from multiple. ## Task1. 2-4 candidate bottleneck layers with hypothesis each.2. Rank by likelihood, cite specific metrics.3. ONE next investigation step per hypothesis.4. ALL conflicting signals (metrics contradicting top hypothesis).5. Flag if data insufficient; name what's missing. ## Input- Results: {results}- Architecture: {architecture}- Load profile: {profile}- Recent changes: {changes} ## Constraints- 2+ supporting metrics for any claim.- Rank by likelihood, not order.- Conflicting signals mandatory.- One step per hypothesis, not a list.- No generic recommendations. ## Output format4 sections: Ranked hypotheses table | Next steps table | Conflicting signals | Data gaps. ## ApproachIdentify the FIRST point in the load profile where things degraded.Example
Input
Test result summary: - Load profile: ramped 0 → 500 RPS over 5 min, then steady at 500 RPS for 25 min - p50 at 500 RPS sustained: 150ms (baseline) → 250ms (5 min in) → 1800ms (15 min in) → 4500ms (25 min in) - p99 climbed from 400ms to 8000ms over the run - Error rate: 0% for first 8 min, 1.2% from min 8-15, 4% from min 15-25 (all "503 service unavailable" from /api/orders) - App service CPU: 40% throughout - App service memory: 60% → 65% (slight rise) - DB CPU: 30% throughout - DB connection pool: 60% → 95% over the run (max 200 connections, climbing to 190 by end) - DB active queries: average query duration grew from 20ms to 1100ms over the run - Network: no anomalies, latency to DB constant 2ms - Stripe API: latency stable at 200ms throughout System architecture: API → Stripe (external) + Postgres (RDS db.r6g.xlarge with 200 connection limit) Load profile: 500 RPS steady, expected to handle this for hours Recent changes: 3 days ago, added a new "order history" page that runs an additional query against the orders table on every checkout
Output
## 1. Ranked hypotheses | Rank | Layer | Evidence | Confidence | |------|-------|----------|------------| | 1 | **Database: connection pool exhaustion** | Pool utilization climbed 60% → 95% over the run; the 503 error rate's onset (min 8) and the latency climb (250ms → 4500ms) tracks the pool saturation curve | HIGH | | 2 | **Database: query duration regression** | Average query duration grew 20ms → 1100ms during the same window; correlates with the new order-history query (deployed 3 days ago), every checkout now runs an extra query against a possibly-unindexed column | HIGH | | 3 | **Application: implicit (downstream of #1, #2)** | App CPU is 40% throughout, so the app itself isn't compute-bound. But it IS waiting on the DB; from the app's perspective, this looks like an app problem, which is misleading | MEDIUM | ## 2. Next steps | Hypothesis | Next investigation step | |------------|-------------------------| | DB pool exhaustion | During a rerun, query Postgres `pg_stat_activity` for connections in `active` or `idle in transaction` longer than 1s: that shows whether connections are held by slow queries or leaked by the app | | Query duration regression | Run EXPLAIN ANALYZE on the new order-history query (likely full table scan on `orders.user_id` if no index exists); compare against the same query before the deploy | | Application implicit | None directly: fixing the DB will resolve. But add a DB-call latency metric per endpoint to detect this pattern faster next time | ## 3. Conflicting signals - App CPU at 40% throughout is INCONSISTENT with "application is the bottleneck": rules out top-of-mind hypotheses around code-level CPU usage. - Network latency to DB constant 2ms argues AGAINST any networking explanation. - Stripe API stable at 200ms argues AGAINST any third-party explanation. - DB CPU at 30% argues against the DB being CPU-bound: supports "the pool is the issue, not the DB compute". ## 4. Data gaps - Query-level breakdown (which queries are taking the most time? top 10 slow queries?) would confirm or refute hypothesis #2. - Connection acquisition time (how long are app requests waiting to GET a connection from the pool?) would tell us if pool size is the issue. - Pre-deploy baseline of pool utilization (was the pool at 95% before the order-history page deploy?) would isolate the recent change as cause. - GC metrics from the app are missing: currently ruled out implicitly via CPU%, but a GC pause investigation would close that loop.
Common pitfalls
- Model jumps to a single conclusion ('it's the database') without acknowledging the multiple possible causes.
- Confidence levels get omitted; every hypothesis treated as equally likely. Re-prompt for ranking with confidence.
- Conflicting signals are skipped: the model wants to be helpful. Force the section.
- Recommendations get generic ('profile the application'). Demand specific, actionable next steps.
Tips
- Feed the full timeline (when did each metric change?): the order of degradation is the most informative signal.
- Include 'recent changes' even if you don't think they're related: the model is good at finding correlations the human glossed over.
- Pair with `bug-repro-from-logs` when you have application/HAR logs alongside the metrics.
- Re-run as data comes in from the next-step investigation: the analysis sharpens with each iteration.
FAQ
When should I suspect GC?
App CPU has spikes (not steady high), p99 is much worse than p95 (long-tail latency from stop-the-world pauses), and there's no DB or network correlation. Check GC pause logs to confirm.
How do I interpret long-tail latency (high p99)?
Long tails come from queuing or rare slow paths. Queue depth, GC, lock contention, slow query outliers all cause them. Look at the gap between p95 and p99: if p99 is 4x p95, something is wrong in the tail.
When are the results inconclusive?
When 3+ layers all show stress signals at the same time. That's usually a sign of cascading failure (one bottleneck causes others). Re-test at a lower load to see what breaks first.
Can I skip metrics and just look at logs?
No. Logs tell you what happened to individual requests; metrics tell you the pattern across thousands. Bottleneck analysis is statistical: you need the metrics view.