p99 latency spikes every few seconds although CPU usage averages only 40% of the limit.
IntermediateTroubleshootingReliability Patterns in Production
Answer
Likely causes → CFS throttling: the container bursts above its CPU limit within a 100 ms period and is paused for the rest of the period. Averages hide it, especially for multi-threaded runtimes (JVM, Go with high GOMAXPROCS).
Diagnose →
rate(container_cpu_cfs_throttled_periods_total{namespace="shop",container="checkout"}[5m])
/ rate(container_cpu_cfs_periods_total{namespace="shop",container="checkout"}[5m])
Fix → Raise or remove CPU limits (keep requests), set GOMAXPROCS to match the limit (automaxprocs) or JVM -XX:ActiveProcessorCount, and re-test.
Prevent → Alert on throttling ratio above 25% for latency-sensitive services.
More on Reliability Patterns in Production
Clients get 503s with body `upstream connect error or disconnect/reset before headers. reset reason: overflow`, and Envoy logs show flag `UO`.AdvancedNGINX ingress returns 504 and logs `upstream timed out (110: Connection timed out) while reading response header from upstream`.BeginnerAfter a 30-second database blip, Postgres keeps rejecting connections with `FATAL: sorry, too many clients already` for 20 minutes.AdvancedCustomers were charged twice during an incident where the payment API timed out.AdvancedEvery rolling deploy produces a short burst of 502s on the AWS ALB.IntermediateRedis restarted and immediately the database CPU hit 100% and the site went down.Advanced