CDN APIs sit at the intersection of control plane and data plane. Whether you are purging cache, updating edge rules, fetching analytics, or invalidating content via API, performance directly impacts deployment velocity and user experience. Yet many teams still monitor CDN APIs with average latency and uptime percentages alone. That approach masks the failures that matter most.
Modern performance analytics replaces averages with distributions, replaces uptime with Service Level Indicators (SLIs), and replaces reactive alerts with error budgets. This guide explains how to instrument, measure, and act on CDN API performance the way SRE teams do at scale. You will learn which percentiles to track, how to define meaningful SLIs and SLOs, and how to build an analytics pipeline that turns raw edge logs into actionable reliability decisions.
1. Why Averages Lie: Understanding Latency Percentiles
Average (mean) latency is mathematically convenient but operationally misleading for CDN APIs. A single origin timeout of 30 seconds can skew an average that otherwise looks healthy. Percentiles solve this by describing the distribution.
A percentile answers: what latency threshold did X% of requests beat? For example:
- p50 (median): 50% of requests were faster than this value. Represents the typical experience.
- p95: 95% of requests were faster. The experience for all but the slowest 5%.
- p99: 99% of requests were faster. The tail that reveals cache misses, cold starts, and regional issues.
- p99.9: The worst 0.1% — critical for high-throughput purge and configuration APIs.
For CDN APIs, latency distribution is almost always multimodal. Cache HITs cluster around 20-60ms at the edge, while cache MISSes that must fetch from origin form a second hump at 300-800ms. A mean blends these two populations into a number that represents neither. If you are new to content delivery concepts, start with our CDN fundamentals guide before diving into percentile analysis.
Consider this real-world distribution from a 10M request sample of a CDN analytics API:
The lesson is clear: a stable p50 with a spiking p99 often indicates origin latency, TLS handshake overhead, or a single under-provisioned PoP. Track percentiles separately for HIT vs. MISS, by region, and by API endpoint. An aggregated p99 across all endpoints hides which API is actually degraded.
2. Defining SLIs That Reflect User Experience
A Service Level Indicator (SLI) is a precise, measured metric that represents a user journey. A good SLI for a CDN API is not CPU utilization or origin connection count. It is what the consumer of the API experiences: latency, availability, and correctness.
| Metric | Edge Processing | Origin Processing | Improvement |
|---|---|---|---|
| Latency (p50) | 8–15 ms | 120–300 ms | 15–20x faster |
| Cache Hit Ratio | 85–95% | N/A | Reduces origin load |
| TLS Handshake | 1–5 ms (nearby PoP) | 50–150 ms | 10–30x faster |
| Bandwidth Cost | $0.01–0.04/GB | $0.05–0.12/GB | 3–5x cheaper |
| Availability | 99.99% (multi-PoP) | 99.9% (single DC) | 10x fewer outages |
For CDN APIs, we recommend four core SLI categories:
Latency SLI
Proportion of valid requests served faster than a threshold, measured at the edge. Example: proportion of GET /api/v1/analytics requests with edge TTFB < 200ms. Measure TTFB, not total download time, to isolate CDN performance from client network.
Availability SLI
Proportion of valid requests that received a non-error response. Count 5xx, 429 overload, and timeouts as failures. Do not count 4xx client errors unless your API is returning them incorrectly due to edge logic. Measure at the edge load balancer, not at the origin, to capture edge failures.
Correctness / Freshness SLI
For purge and cache-control APIs, correctness means the action took effect within the promised window. Example: proportion of purge requests where content is globally invalidated within 5 seconds. This requires synthetic validation from multiple PoPs.
Throughput / Durability SLI
For log delivery and analytics ingestion APIs, measure event loss. Example: proportion of log events delivered without loss within 60 seconds.
Each SLI needs a clear definition of valid events, measurement window, and data source. See our overview of CDN performance metrics for a breakdown of data sources from edge logs to RUM. And for architectural context on where these measurements occur, review the CDN architecture overview.
| SLI Type | Example Definition | Measurement Point | Recommended SLO |
|---|---|---|---|
| Latency | p95 TTFB < 200ms for cache HITs; p95 < 650ms for MISS | Edge (client-facing) | 95% over 28 days |
| Availability | Non-5xx responses / valid requests | Edge LB + synthetic | 99.9% over 30 days |
| Purge Freshness | Purge globally effective < 5s | Synthetic probes (6+ PoPs) | 99% over 7 days |
| Error Rate | 5xx + timeout rate < 0.1% | Edge logs | 99.9% over 28 days |
| Durability | Log/analytics delivery > 99.95% | Pipeline audit | 99.95% over 30 days |
Start with two SLIs: one for latency and one for availability. Adding more before you have reliable measurement creates noise. Each SLI should have an SLO (target) and be owned by a team that can actually change the outcome.
3. From SLOs to Error Budgets: Making Reliability Actionable
An SLO is your internal target for an SLI — for example, 99.9% availability over 30 days. An error budget is the inverse: the amount of unreliability you are allowed before you must stop and fix things. For 99.9% over 30 days, the budget is 0.1%, or about 43 minutes of total downtime or 43,200 failed requests per 43.2M requests.
Error budgets turn reliability from an abstract goal into a deployment policy:
- Budget available (>50% remaining): Ship normally. Experiment with new edge logic, compression, or routing.
- Budget burning (25-50% remaining): Increase caution. Require additional review for risky changes, add canary analysis.
- Budget exhausted (0%): Feature freeze. Only reliability fixes, rollbacks, and hardening ship until the window resets or burn rate recovers.
For CDN APIs, burn rate matters more than absolute budget. A slow burn (e.g., p95 creeping from 180ms to 260ms over two weeks) indicates capacity or cache efficiency decay. A fast burn (error rate jumping from 0.05% to 0.8% in 10 minutes) indicates a bad config push or origin failure. Configure multi-window burn-rate alerts: 5-minute and 1-hour windows for fast burns, 6-hour and 24-hour for slow burns.
Crucially, error budgets must be visible to product and engineering. A dashboard that shows budget remaining, burn rate, and the top contributors (endpoint, PoP, status code) aligns incentives. When a team sees that the /purge endpoint consumed 70% of this month's error budget due to origin timeouts, prioritizing origin shielding becomes obvious. For APIs exposed to the public internet, factor in abuse and attack traffic — our guide to CDN DDoS protection explains how to exclude mitigated attack traffic from SLI calculations so you do not burn budget on filtered requests.
4. Building the Analytics Pipeline
Reliable SLI measurement requires a pipeline that preserves high-cardinality data without exploding cost. Sampling averages at collection time destroys percentile accuracy, so design for histograms and counts at the edge.
- Collect at the edge: Emit structured logs from every PoP with request ID, endpoint, cache status (HIT/MISS/PASS), edge TTFB, origin TTFB, status code, PoP ID, and ASN. Use nanosecond timestamps synchronized via NTP.
- Aggregate with histograms: Do not average. Use Prometheus-style histograms or DDSketch at the edge to compute percentiles without storing every sample. A typical bucket set for CDN APIs: 10ms, 25ms, 50ms, 100ms, 200ms, 400ms, 800ms, 1600ms, 3000ms.
- Centralize with cardinality control: Ship histograms to a central time-series store (e.g., ClickHouse, BigQuery, or Mimir) with labels for endpoint, cache status, and PoP, but avoid high-cardinality labels like user ID or URL path.
- Validate with synthetics: Supplement logs with synthetic probes from multiple geographies that measure purge freshness and availability from the outside. Logs tell you what happened; synthetics tell you what the user saw.
Retention matters. Keep raw histograms for 30 days for SLO windows, and downsample to daily p50/p95/p99 for 13 months for trend analysis. This lets you answer both what burned the budget today and whether p99 has degraded quarter-over-quarter.
5. Instrumentation: Code and Queries
Implementation determines whether your percentiles are trustworthy. Below are production-ready patterns for instrumenting CDN APIs and querying SLIs.
Edge Logging (VCL / Nginx / Workers)
Emit a consistent log line that includes both edge and origin timing. The delta reveals where latency originates.
# Example: Nginx log format for CDN API SLI measurement
log_format sli '$time_iso8601 $request_id $remote_addr '
'method=$request_method endpoint=$uri '
'status=$status cache=$upstream_cache_status '
'edge_ttfb=${request_time} origin_ttfb=${upstream_response_time} '
'pop=$pop_id bytes=$bytes_sent';
# Query: p95 edge TTFB for HITs on /api/v1/config (Prometheus)
histogram_quantile(0.95,
sum by (le) (
rate(cdn_api_request_duration_seconds_bucket{
endpoint="/api/v1/config",
cache_status="HIT"
}[5m])
)
)
SLO Burn-Rate Alert
Alert when you are consuming error budget too fast, not just when an SLO is violated.
# Burn rate = error rate / error budget
# SLO 99.9% => budget 0.1% => burn rate 1 = exactly on budget
# Alert if burn rate > 5 for 10 minutes (fast burn) OR > 1 for 60 minutes (slow burn)
- alert: CDN_APIFastBurn
expr: |
(
sum(rate(cdn_api_requests_total{status=~"5.."}[5m]))
/
sum(rate(cdn_api_requests_total[5m]))
) / 0.001 > 5
for: 10m
labels: { severity: critical }
annotations: {
summary: "CDN API fast burn: {{ $value }}x budget"
}
Client-Side Validation
For purge freshness SLI, validate from the outside. This Node.js probe checks global invalidation:
// Synthetic purge freshness check from multiple PoPs
async function checkPurgeFreshness(url, purgeApi) {
const start = Date.now();
await purgeApi.post('/purge', { url });
// Poll edge until 200 with fresh x-cache header or timeout
for (let i = 0; i < 10; i++) {
const res = await fetch(url, { cache: 'no-store' });
if (res.headers.get('x-cache') === 'MISS' && res.ok) {
return Date.now() - start; // freshness latency
}
await new Promise(r => setTimeout(r, 500));
}
throw new Error('Purge not globally effective within 5s');
}
Store the result as a histogram metric cdn_purge_freshness_seconds and define your SLI as the proportion of probes succeeding within the SLO threshold. For a broader foundation on how caching and edge logic affect these numbers, see what is a CDN and how edge tiers interact.
6. Putting It Together: A Practical Rollout
You do not need a full observability platform to start. Begin with one API endpoint, one latency SLI, and one availability SLI.
Week 1: Instrument edge logs with histograms for your highest-traffic API (often /api/v1/analytics or /purge). Build a dashboard showing p50, p95, p99 split by HIT/MISS and by PoP. You will immediately spot regional outliers.
Week 2: Define SLOs based on the last 28 days of data, not aspirations. If your current p95 for MISS is 620ms, set the SLO at 650ms. Tighten it quarterly as you improve. Create an error budget dashboard and share it in sprint planning.
Week 3: Add burn-rate alerts and synthetic probes for purge correctness. Run a game day: intentionally slow the origin by 300ms and verify that p99 alerts fire while p50 stays green. This validates that your percentiles are sensitive to tail failures.
Over time, extend to per-customer or per-plan SLIs if you offer tiered performance. A common pattern is stricter p95 SLOs for enterprise purge APIs while keeping relaxed SLOs for free-tier analytics. The key is that every SLO has a clear owner, a defined measurement, and a consequence when the budget exhausts.
CDN API performance analytics is not about collecting more metrics. It is about collecting the right distributions, defining SLIs that match user pain, and using error budgets to make tradeoffs explicit. When latency percentiles, SLIs, and budgets align, releases get safer, incidents get clearer, and performance work gets prioritized because it is measured in budget, not just milliseconds.