Your server didn't die at deploy. It died a week later — when a memory leak finally ate the last megabyte, a query that was "fine in staging" started scanning millions of rows, and a traffic spike turned a slow endpoint into a timeout cascade. You only found out when the pager went off at 3 a.m. The post‑mortem said "resource exhaustion." No kidding. The real question is: how do you get ahead of it?
This is where a well‑crafted prompt to an LLM can act like a senior SRE who never sleeps. Not the vague "optimize my code" kind — the kind that forces the model to read your heap profile, your query plan, and your logs, name the exact culprit, and propose a fix with numbers. Below are the prompts that do that, each tied to a real failure mode. Use them before the next incident, not after.
When the Heap Looks Like a Ski Slope: Interpreting Memory Profiles
You have a heap snapshot from Node.js (--inspect + Chrome DevTools) or a Django process showing steadily climbing RSS. The LLM can't run the profiler, but it can read the output if you feed it right. More on the topic: “The LLM Detective: DevTools Prompts That Reproduce Bugs, Read Stack Traces and Set Breakpoints Instead of Guessing”.
Prompt:
You are a Node.js memory debugging expert. I will give you the output of `process.memoryUsage()` sampled every 10 seconds for 30 minutes, plus a heap snapshot summary (top 20 constructors by retained size). Identify the most likely leak pattern: closure retention, event‑listener accumulation, global cache without eviction, or buffer mishandling. For each suspect, give the exact line of code or module to inspect, and suggest one instrumentation step to confirm. Respond in a table with columns: Suspect, Evidence from data, Next check.
More on the topic: “The 800-Line Function That Refuses to Die: A Refactoring Prompt Kit That Maps Dependencies Before It Touches a Single Line”.
Example: A team pasted 180 samples showing heapUsed rising from 80 MB to 420 MB. The LLM spotted that Array retained size grew linearly while String stayed flat — pointing to an unbounded array of request objects stored in a module‑level cache. The fix: replace with an LRU cache of max 1000 entries. Memory stabilised at 95 MB. More on the topic: “CI/CD Without Surprises: 12 Prompts That Make the LLM Write Pipelines, Fix Broken Builds and Explain Terraform Plans in Plain English”.
Why it works: LLMs are good at pattern‑matching across time‑series and constructor names. They won't magically know your code, but they'll tell you where to look — which is half the battle. More on the topic: “Your Monolith Looks Fine From the Outside: A Prompt Kit That Makes an LLM Draw the Microservice Map — and Point at the Seams Where It Tears”.
The Query That Looked Innocent: Reading EXPLAIN Plans Like a Detective
A Django endpoint that took 200 ms in development now takes 4 seconds under load. The database is fine — the query plan changed because the table grew past a tipping point.
Prompt:
You are a PostgreSQL query‑plan analyst. I will paste the output of `EXPLAIN (ANALYZE, BUFFERS)` for a Django ORM‑generated query. Identify: (1) the operation with the highest actual time, (2) whether a sequential scan is happening on a large table, (3) any nested loop that could be replaced by a hash join, (4) missing indexes suggested by the plan. Then rewrite the query (or the ORM call) to use the suggested index, and estimate the expected speedup based on row counts. Format: Problem → Fix → Expected gain.
Example: The plan showed a Seq Scan on orders (2.3M rows) inside a nested loop for a report query. The LLM suggested adding a composite index on (user_id, created_at) and rewriting the ORM filter() to avoid Q objects that prevented index usage. After applying, the query dropped from 4.1 s to 180 ms. More on the topic: “Go, LLM, and the Race Against Races: How to Prompt for Idiomatic Concurrency, Explicit Errors, and Context-Aware Code”.
Key insight: The LLM won't know your schema, but it can read the plan's cost estimates and row counts. That's enough to spot the usual suspects: missing indexes, implicit casts, and N+1 patterns hidden in prefetch_related misuse.
Under Load, Everything Breaks: Stress‑Test Logs as a Diagnosis Tool
You ran wrk or locust and got a flood of 502s and timeouts. The logs are noisy, but the LLM can sift through them.
Prompt:
You are a performance engineer. Below are 200 lines from an application log during a load test (mix of INFO, WARN, ERROR). The test ramped from 10 to 500 concurrent users over 5 minutes. Identify: (1) the first error that appeared, (2) any repeating pattern (e.g., connection pool exhaustion, timeout on a specific endpoint), (3) the most likely bottleneck (CPU, memory, DB connections, or external API). Suggest one configuration change (e.g., pool size, timeout value) and one code‑level fix. Answer in plain text, no markdown.
More on the topic: “Green Tests, Broken Contracts: 12 LLM Prompts That Hunt Reentrancy, Oracle Holes, and Gas Leaks Before Your Solidity Audit”.
Example: Logs showed TimeoutError: Knex: Timeout acquiring a connection starting at 120 concurrent users. The LLM correctly guessed the pool size was too small (default 2 in some setups) and recommended raising it to 20, plus adding a retry with backoff. The team also found a missing index that made each request hold a connection longer.
From Symptom to Fix: A Real‑World Walkthrough
Imagine a Django + Node.js hybrid: a Node.js API gateway proxying to a Django backend. After a week, the gateway's memory climbs, Django's response times degrade, and under load the whole thing 502s.
The team used three prompts:
- Memory: Fed Node.js heap snapshots to the LLM, which identified a leak in a WebSocket connection map that never removed closed sockets. Fix: add a
closeevent handler to delete entries. - Query: Fed Django's slow‑query log with
EXPLAINplans. The LLM spotted a missing index on a foreign key used in afilter()that ran on every request. Fix: add index, query time dropped 90%. - Load: Fed load‑test logs. The LLM saw that Django's
CONN_MAX_AGEwas 0 (new connection per request), causing connection storms. Fix: set to 60 seconds, reducing DB load by half.
Result: no more 3 a.m. pages.
The Prompt That Turns Logs Into a Timeline
Sometimes you have logs from multiple services and need to correlate. This prompt forces the LLM to build a timeline and find the trigger.
Prompt:
You are a distributed systems debugger. I will paste logs from three services (Node.js gateway, Django app, PostgreSQL) with timestamps. Reconstruct a timeline of the incident: what happened first, what was the trigger, and what was a consequence. Highlight any clock skew or missing correlation IDs. Then propose one change to logging that would make the next incident easier to diagnose.
More on the topic: “System Design: How Scaling Turns 1,000 Users into 10 Million”.
Example: The LLM noticed that the first sign was a slow query in PostgreSQL logs, followed by Django timeouts, then gateway 502s. It recommended adding a request ID propagated across services — which the team implemented.
Don't Ask for "Optimization" — Ask for Numbers
Vague prompts get vague answers. Instead of "how to fix memory leak," ask "what is the retained size of the top 5 objects, and which one grows linearly?" The LLM will give you a number‑driven answer.
For more on using LLMs in DevOps, see "From Dockerfile to Debugging Pods: 12 Prompts That Turn an LLM Into Your DevOps Partner".
Your Next Step: Build a Prompt Library for Your Stack
Start with three prompts: one for memory, one for queries, one for load logs. Run them weekly on a sample of production data. You'll catch the slow leaks before they become outages. And when the pager does go off, you'll have a diagnosis in minutes, not hours.
The goal isn't to replace your APM — it's to make sense of the data you already have, faster.
Rules and figures are stated as of November 2026.