# AEM performance diagnostics — tools, CDN log analysis, load testing

> **Verified:** 2026-09 against https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/using-cloud-manager/manage-logs and https://experienceleague.adobe.com/en/docs/experience-manager-learn/cloud-service/caching/cdn-cache-hit-ratio-analysis

Open this when you need evidence: which tool produces which number, how to compute a hit ratio per path, and how to run a load test that means something.

## Tool per question

| Question | Tool | Where |
|---|---|---|
| Which URLs are slowest? | `request.log` + `rlog.jar` | Cloud Manager → Download Logs (Publish), or `aio cloudmanager:environment:tail-log` |
| Why is one request slow? | Developer Console → **Status** (OSGi, Sling Models) and **Queries** | Cloud Service Developer Console per environment |
| Is my query indexed? | Explain Query / Query Performance | Developer Console → Queries (Cloud); Tools → Operations → Diagnosis (6.5) |
| Where is the time at the edge? | CDN logs (`ttfb`, `cache`), `Server-Timing` response header | Cloud Manager → Download Logs → CDN row |
| Are threads blocked? | 3–5 thread dumps, 5–10 s apart | Adobe support or the local SDK; compare stacks across dumps |
| Is memory leaking? | GC logs, heap dump | Adobe support for production; reproduce on the SDK where possible |
| Field Core Web Vitals | CrUX / a RUM script | Not a server-side measurement — never judge LCP from Lighthouse alone |
| Capacity | JMeter / Gatling / k6 against **stage**, with the CDN in the path | Coordinate large tests with Adobe support per your program's policy |

Application performance monitoring (for example New Relic) is entitlement-dependent. Check what your program actually has provisioned before designing a plan around it; the log surfaces above are always available.

## CDN log analysis

CDN logs are JSON, one object per request, and the format is fixed. The fields that matter:

| Field | Use |
|---|---|
| `cache` | `HIT`, `MISS` or `PASS` — `PASS` means the response was explicitly marked uncacheable |
| `ttfb` | Time to first byte in milliseconds |
| `url`, `host`, `method` | Group by these |
| `status` | Separate 404 storms from real traffic |
| `res_age` | How long the object had been cached |
| `res_ctype` | Split HTML from images and clientlibs — they have different targets |

Hit ratio for HTML by path prefix, from a downloaded log:

```bash
jq -r 'select(.res_ctype|test("text/html")) | "\(.cache) \(.url)"' cdn-*.log \
  | awk '{split($2,p,"/"); key=p[2]"/"p[3]"/"p[4]; tot[key]++; if($1=="HIT") hit[key]++}
         END{for(k in tot) printf "%-40s %5d req  %5.1f%% hit\n", k, tot[k], 100*hit[k]/tot[k]}' \
  | sort -k2 -rn
```

Read it as three separate problems:
- A high **`PASS`** share means something is setting `Cache-Control: private`/`no-store`, or a cookie is on the path — an application bug.
- A high **`MISS`** share with low `res_age` means over-invalidation (`statfileslevel`, a publish loop) or cache-key explosion (query strings, unbounded selectors).
- A low `ttfb` on `MISS` and a high one on `HIT` means you are reading the wrong tier — check that you filtered to the right host.

`LogForwarding` config-pipeline configs push the same logs to a destination continuously, which is how you get this as a dashboard rather than an ad-hoc download.

## Reading `request.log`

```bash
java -jar rlog.jar -n 20 request.log          # 20 slowest requests
java -jar rlog.jar -n 20 -m 1000 request.log  # slowest, ignoring anything under 1 s
```

Pair every slow URL with its `cache` value from the CDN log for the same window. A slow URL that is always a `HIT` at the edge is not a publish problem.

## Oak query limits

Two Oak settings decide when a bad query becomes an exception instead of a warning: a read limit and an in-memory result limit (`queryLimitReads`, `queryLimitInMemory` on the `QueryEngineSettings` MBean). On Cloud Service these are platform-managed — you cannot raise them, which is deliberate: a query that trips them is a missing index, not a tuning opportunity. Treat `Traversed N nodes` in `error.log` as a failing test.

## Load testing that means something

1. Run against **stage**, which mirrors prod, with the CDN and dispatcher in the path. A test that hits publish directly measures nothing you ship.
2. Use a realistic URL mix, including the long tail — a test that hammers one page measures your cache, not your application.
3. Warm the cache the way real traffic does, then report cached and uncached numbers separately.
4. Model authoring load separately on the author tier: concurrent editors, asset uploads, rollouts.
5. Record the CDN hit ratio the test achieved next to the latency numbers. Without it the result is not reproducible.
