CDN Error Rate Monitoring: 4xx, 5xx Trends, and Anomaly Detection
A 0.3% 5xx spike at the edge can mean thousands of failed API calls per minute. Learn how to instrument, trend, and detect anomalies in CDN error rates before users notice.
Every request that traverses your CDN tells a story. Most end with a successful 2xx or a cache-efficient 3xx, but the small percentage that return 4xx and 5xx status codes contain disproportionate operational value. Left unmonitored, a 0.5% uptick in 5xx errors can translate to thousands of failed checkouts, API timeouts, or broken assets per minute at scale. Effective CDN error rate monitoring is not about counting failures after the fact — it is about detecting shifts in client and server behavior in real time, correlating them with deployments, cache states, and origin health, and triggering automated or human intervention before user impact escalates. This guide provides a practical framework for monitoring, trending, and detecting anomalies in CDN error rates, built for engineers responsible for availability and performance. We will cover metric design, trend interpretation, and production-ready anomaly detection techniques you can implement today.
Why Error Rate Is Your Leading Availability Indicator
Latency and throughput get the dashboards, but error rate is the most sensitive leading indicator of availability. Unlike synthetic checks that sample a few paths, error rate aggregates every real user request across all Points of Presence (POPs). When you understand how CDN works to terminate TLS, apply caching logic, and proxy to origin, you realize the CDN is the ideal vantage point to observe both client-side misuse and server-side failure.
A well-instrumented CDN emits structured logs for every request: status code, cache status (HIT, MISS, PASS, STALE), POP, ASN, URL path, and origin latency. Aggregating these into error rates gives you three critical capabilities:
- Blast radius assessment: Is the error isolated to one POP, one origin, or global?
- Cache correlation: Are 5xx errors coming from stale-while-revalidate or collapsed forwarding?
- Client vs. server attribution: Is the failure due to bad client input or infrastructure?
Decoding 4xx vs. 5xx at the Edge
Treating all 4xx and 5xx as “errors” obscures root cause. At the CDN layer, the distinction is critical.
| 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 |
4xx: Client Errors That Still Need Monitoring
4xx responses indicate the client sent a request the server could not or would not fulfill. They are often dismissed as “user fault,” but at the CDN they frequently signal configuration or deployment issues:
- 400 Bad Request / 411 Length Required: Malformed requests, often from bots or broken SDKs. A sudden rise suggests a bad client release.
- 401 Unauthorized / 403 Forbidden: Spikes correlate with CDN security policy changes, WAF rule updates, expired signed URLs, or hotlink protection misconfigurations. Monitor these alongside your CDN architecture overview to map token validation at the edge.
- 404 Not Found: The most common 4xx. A deployment that renames assets without proper cache purging or redirect logic will create a sustained 404 plateau. Track 404 rate per content type.
- 429 Too Many Requests: Intentional rate limiting. High 429 rates are healthy if expected, but an unexpected surge indicates scraping or a retry storm.
Key insight: 4xx errors are usually cacheable and cheap for origin, but they pollute cache and analytics if not filtered. More importantly, a 404 storm after a purge can look like an outage to real users.
5xx: Server Errors That Demand Immediate Action
5xx errors mean the server (edge or origin) failed to fulfill a valid request. These directly impact SLOs and require burn-rate alerting.
- 500 Internal Server Error / 502 Bad Gateway: Origin returned an invalid response or crashed mid-stream. Often tied to origin overload or deployment rollback.
- 503 Service Unavailable / 504 Gateway Timeout: Origin timeout or connection failure. At the CDN, this frequently means origin keepalive exhaustion, TLS handshake failure, or congestion. Correlate with origin latency percentiles.
- 520-530 Edge-specific codes: Vendors like Cloudflare use 520 (unknown error), 521 (origin down), 522 (connection timeout), 530 (origin DNS). These never hit origin logs — you only see them at the edge.
Unlike 4xx, 5xx should almost never be cached. Ensure your CDN caching strategies correctly bypass cache on 5xx and serve stale-on-error where appropriate.
| Category | Codes | Typical CDN Cause | Primary Signal | Action |
|---|---|---|---|---|
| Client Misconfig | 400, 411 | Bot traffic, SDK bug | High 400 rate on single User-Agent | Filter, block, fix client |
| Auth / WAF | 401, 403 | Signed URL expiry, WAF false positive | 403 spike after rule deploy | Review WAF, rotate tokens |
| Missing Asset | 404 | Bad purge, rename without redirect | 404 on HIT, path-specific | Purge correctly, add fallback |
| Rate Limited | 429 | Edge rate limiting, bot mitigation | 429 + high RPS per IP | Tune thresholds |
| Origin Failure | 500, 502 | App crash, invalid headers | MISS + high origin latency | Rollback, scale origin |
| Origin Unreachable | 503, 504, 521-524 | Timeout, DNS, TLS failure | POP-specific, no origin log | Check origin health, network |
Core Metrics: Beyond Simple Percentages
Raw error rate is a starting point. Production monitoring requires dimensional, SLO-aware metrics.
1. Normalized Error Rate: error_rate = (4xx + 5xx) / total_requests sliced by POP, cache status, path pattern, and ASN. Always compute separately for 4xx and 5xx — combining them hides origin failures behind client noise.
2. Origin Error Ratio: origin_5xx / origin_requests where origin_requests = MISS + PASS + STALE. This isolates origin health from edge-served traffic. A 2% origin 5xx with 90% cache hit ratio is a 0.2% global 5xx — easy to miss without this slice.
3. Error Budget Burn Rate: If your SLO is 99.9% availability (43m error budget/month), burn rate = current_error_rate / (1 - SLO). A burn rate of 10x means you will exhaust the monthly budget in ~3 days. Alert on burn rate, not absolute rate.
4. Cache Poisoning Indicator: Ratio of 404/403 served as HIT. A cache that stores 404s due to misconfigured Cache-Control will amplify a transient origin 404 into a prolonged outage.
Analyzing Trends: Seasonality, Deploys, and Drift
Error rates are never flat. Understanding normal variation prevents alert fatigue.
Seasonality: Most CDNs show diurnal and weekly patterns. 4xx rates often rise during business hours as API clients generate more validation errors, while 5xx may spike during nightly batch jobs that stress origin. Compare week-over-week, not just hour-over-hour. A 0.2% 5xx at 3 AM is more anomalous than 0.4% at peak.
Deployment correlation: Overlay error rate time series with deploy markers, cache purge events, and WAF rule pushes. A step-function increase in 404 within 2 minutes of a frontend deploy is almost certainly an asset path regression. Use annotations in Grafana or Datadog to make this visual.
Drift vs. spike: Slow drift (e.g., 5xx rising 0.02% per day for a week) indicates capacity exhaustion or memory leak at origin — easy to miss with spike-only alerts. Track 7-day rolling averages and slope. A positive slope for 3 consecutive days should trigger a low-severity investigation ticket.
Protocol and POP slices: If you have migrated to HTTP/3 and QUIC, segment error rates by protocol. QUIC handshake failures manifest as 0-RTT 5xx or connection resets that do not appear in HTTP/2 metrics. Similarly, a single POP showing elevated 503 while others are healthy points to regional origin routing or Anycast issues, not global failure.
Anomaly Detection: From Static Thresholds to Adaptive Models
Static thresholds (“alert if 5xx > 1%”) fail at scale. They are either too noisy during traffic troughs or too slow during peaks. Modern CDN monitoring uses adaptive, statistical detection.
1. EWMA and Holt-Winters for Seasonal Baselines
Exponentially Weighted Moving Average (EWMA) gives more weight to recent data while smoothing spikes. For seasonal traffic, Holt-Winters adds trend and seasonality components. Compute expected error rate μ(t) and standard deviation σ(t) per 5-minute bucket, per status class.
Alert when observed_rate > μ + 3σ for two consecutive buckets. This catches sustained deviations while ignoring single-bucket blips from log delivery jitter.
2. Z-Score and Modified Z-Score
For high-cardinality breakdowns (per URL pattern, per POP), z-score is lightweight and explainable. Use median absolute deviation (MAD) instead of standard deviation for robustness to outliers:
SELECT pop, status_code,
(error_rate - median_rate) / (1.4826 * mad) AS mod_z
FROM (
SELECT pop, quantile(0.5)(error_rate) AS median_rate,
quantile(0.5)(abs(error_rate - median_rate)) AS mad
FROM cdn_metrics WHERE timestamp > now() - INTERVAL 7 DAY
)
A modified z-score > 3.5 is a strong anomaly signal. Run this every 5 minutes over a 7-day sliding window.
3. SLO Burn-Rate Alerting
The most actionable model for 5xx is multi-window burn-rate. Google SRE recommends two windows:
- Fast burn: 5-minute error rate > 10x SLO burn → page immediately
- Slow burn: 1-hour error rate > 2x SLO burn → ticket, investigate
This balances sensitivity to large outages with tolerance for small blips.
4. Machine Learning for Unknown Unknowns
Isolation Forest or autoencoders on feature vectors (error rate by status, POP, cache status, origin latency) can surface novel failure modes — e.g., a simultaneous rise in 403 and origin latency that indicates WAF-induced origin slowdown. Use ML as a complement, not replacement, for rule-based alerts. Always make ML alerts explainable by surfacing top contributing dimensions.
(
sum(rate(cdn_requests_total{status=~"5.."}[5m]))
/ sum(rate(cdn_requests_total[5m]))
)
> (
avg_over_time(cdn_5xx_rate_ewma[1h])
+ 3 * stddev_over_time(cdn_5xx_rate_ewma[1h])
)
and increase(cdn_5xx_anomaly_count[10m]) > 1
Pair with recording rules that pre-compute EWMA to reduce query load. Evaluate every 1m, for 5m.
Building Alerts and Runbooks That Actually Help
Detection without response is just expensive logging. Design alerts for actionability.
Alert hierarchy:
- P1 - Page: Global 5xx burn rate >10x, or any POP 5xx >5% for 2m. Auto-failover to stale cache or secondary origin.
- P2 - Ticket: 4xx anomaly z-score >3.5 on critical path (/api/*, /checkout/*). Requires human triage within 30m.
- P3 - Log: Slow drift in 404 rate, cache HIT 404 ratio >1%. Review in weekly reliability meeting.
Each alert must include context: top 5 URL patterns by error contribution, cache status breakdown, POP distribution, and deploy correlation. Link directly to logs filtered to the anomaly window.
Mitigation patterns: Enable stale-while-revalidate and stale-if-error to serve stale content on 5xx, use load shedding at the edge (return 503 with Retry-After instead of hammering origin), and implement circuit breakers that short-circuit origin fetches when origin 5xx exceeds 20% for 30s.
Conclusion
CDN error rate monitoring is not a dashboard — it is a control system. By separating 4xx and 5xx, normalizing by cache and origin, tracking burn rates, and applying adaptive anomaly detection, you turn noisy logs into early, actionable signals. Start with origin-isolated 5xx burn-rate alerts and EWMA baselines for 4xx, then layer per-POP z-scores and ML for coverage. The goal is simple: detect the shift before users feel it, and give responders the exact slice they need to fix it.
Frequently Asked Questions
What is an acceptable CDN error rate for 5xx errors?
For most production CDNs, sustained 5xx rates should stay below 0.1% of total requests, with an SLO of 99.9% successful origin responses. Burst tolerance is higher, but any 5xx rate above 0.5% for more than 2-5 minutes warrants investigation. Edge-generated 5xx codes like 530 or 503 should be near zero under normal conditions.
How do you distinguish CDN edge errors from origin errors?
Check the CDN response header such as CF-Cache-Status, X-Cache, or Age and the error body. Edge errors often have distinct codes like 520-530, no corresponding origin log entry, and low time-to-first-byte. Origin errors correlate with origin logs, higher origin latency, and cache MISS or PASS status. Correlating edge logs with origin access logs is the definitive method.
Should 4xx errors trigger alerts?
Selective alerting is best. Avoid alerting on absolute 4xx counts and instead monitor for anomalous spikes. Alert on 404 spikes for bad deployments or cache purge errors, 403/401 spikes for WAF or authentication misconfigurations, and 429 for rate limiting. Use anomaly detection with z-scores rather than static thresholds to avoid noise from normal client errors.
What is the best method for CDN anomaly detection?
A hybrid approach works best: use exponentially weighted moving average (EWMA) or Holt-Winters for seasonality-aware baselines on low-cardinality metrics, and modified z-score or isolation forest for high-cardinality breakdowns by POP, URL, and status code. Combine these with SLO burn-rate alerting to prioritize user-impacting anomalies over statistical noise.