Troubleshooting Production Performance in a Microservices Platform
System DesignModel answerLast updated
Debug and resolve a microservices system suffering from elevated latency, errors, and scaling instability using observability data and incident response.
You're on-call for a microservices platform running on Kubernetes. Users are reporting slow page loads, and monitoring alerts show elevated tail latency, increased error rates, and unstable replica counts that keep bouncing up and down.
Walk through your complete incident response process:
-
Investigation approach: What data sources would you examine and in what order? What specific metrics, log patterns, and trace characteristics would you look for?
-
Diagnostic methodology: What are the most likely root causes, and how would you systematically test each hypothesis? What commands, queries, or tools would you use?
-
Remediation strategy: What immediate actions would you take to restore service stability? What longer-term fixes would prevent recurrence?
Focus on practical, evidence-based reasoning. Explain how you would distinguish between different failure modes and what signals would confirm each diagnosis.
Hints
Hint 1
Start by determining scope and timing—did this affect one component or many, and did it correlate with any changes or events?
Hint 2
CPU throttling is a common hidden cause of tail latency even when average utilization looks reasonable.
Hint 3
Retry amplification can create cascading load where upstream request volume far exceeds original client traffic.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer: Troubleshooting Production Performance Issues
A strong answer demonstrates structured incident response: stabilize first, diagnose with evidence, and implement durable fixes. Think like an SRE running a production incident.
1. Initial Assessment (2-3 minutes)
Before diving into metrics, narrow the problem space by asking:
Scope questions:
- Which services are affected? Is this isolated to one component or system-wide?
- Is the issue present in all availability zones or just one region?
Timing questions:
- When did symptoms start? Was it gradual or sudden?
- Did any deployments, configuration updates, or scheduled jobs run around that time?
Quantification:
- What are the actual numbers? (e.g., "p99 jumped from 180ms to 3.5s, error rate is now 6%, replicas oscillating between 12 and 45")
- Is request volume actually higher, or is the same traffic becoming more expensive?
This last distinction is critical—you're either facing increased demand or reduced capacity.
2. Observability: Top-Down Investigation
Work from the edge inward, following the request path:
Ingress/Load Balancer Layer:
- Request rate, error codes (4xx/5xx), connection counts
- Backend response times reported by the load balancer
Service Layer (RED metrics):
- Request rate, error percentage, latency distribution per endpoint
- Queue depth and concurrent request counts
Pod/Container Level (USE metrics):
- CPU: actual usage versus requests/limits, and throttling periods
- Memory: usage versus limits, OOMKills, garbage collection frequency
- Container restarts and exit reasons
Node Level:
- Resource pressure (CPU, memory, disk I/O)
- Network: conntrack table usage, packet drops
- Kubelet eviction events
Cluster Control Plane:
- Pods stuck in Pending state
- HPA current versus desired replicas
- Cluster autoscaler activity logs
- CoreDNS performance and error rate
Downstream Dependencies:
- Database connection pool saturation and query latency
- Cache hit rates (a sudden drop indicates cold caches)
- Message queue consumer lag
Key Prometheus Queries
# Detect CPU throttling (often invisible in standard dashboards)
rate(container_cpu_cfs_throttled_periods_total[5m])
/ rate(container_cpu_cfs_periods_total[5m])
# Tail latency by service
histogram_quantile(0.99,
rate(http_request_duration_seconds_bucket[5m]))
# Retry amplification detection
rate(istio_requests_total{response_code=~"5.."}[5m])
3. Diagnostic Commands
# Recent cluster events (evictions, scheduling failures, OOM)
kubectl get events -A --sort-by=.lastTimestamp | tail -30
# Resource consumption by pod
kubectl top pods -A --sort-by=cpu
# Identify unhealthy pods
kubectl get pods -A | grep -vE 'Running|Completed'
# Examine specific pod details
kubectl describe pod <name> -n <namespace>
# Check HPA behavior
kubectl get hpa -n <namespace> -w
kubectl describe hpa <name> -n <namespace>
# Review recent deployments
kubectl rollout history deployment/<name> -n <namespace>
# Cluster autoscaler logs
kubectl logs -n kube-system -l app=cluster-autoscaler --tail=100
# Access container from previous crash
kubectl logs <pod> -n <namespace> --previous
Distributed Tracing: Pull representative traces at p99 latency. Look for:
- Which service span dominates total duration
- Fan-out patterns (one request triggering many downstream calls)
- Retry attempts visible in trace spans
- Connection pool wait time
Log Analysis: Aggregate errors by pattern:
- Timeouts: "context deadline exceeded", "request timeout"
- Connection issues: "connection refused", "no route to host"
- Resource exhaustion: "too many open files", "cannot allocate memory"
Check whether errors cluster on specific pods or nodes.
4. Common Root Causes and Their Signatures
1. Recent deployment introduced a regression
- Signature: Performance degraded at exact rollout timestamp; new ReplicaSet shows higher latency
- Test: Compare metrics between old and new pod versions, consider rollback
2. CPU throttling despite "normal" utilization
- Signature: Throttle ratio >25%, p99 spikes while p50 stays reasonable, CPU limit is tight
- Cause: CFS quota enforcement pauses threads mid-request even when average CPU looks fine
3. Retry cascade (metastable failure)
- Signature: Upstream request volume 10x+ client requests, every timeout triggers retries at multiple layers
- Effect: Each failure increases load, creating a self-reinforcing cycle
4. Database or cache bottleneck
- Signature: Traces show requests waiting on database spans, connection pool exhausted, slow queries in DB logs, or cache hit rate dropped after restart
- Effect: Application threads block waiting for backend responses
5. Horizontal Pod Autoscaler thrashing
- Signature: Replica count oscillates rapidly, pods cycle between Ready and NotReady
- Causes: Metric lag, new pods not truly ready (cold JVM, empty cache), aggressive scale-down before next traffic spike
6. Insufficient cluster capacity
- Signature: HPA requests 50 replicas but only 30 are Running/Ready, remaining pods Pending
- Cause: Cluster autoscaler lag (2-5 min node boot time), resource quotas, or no available instance types
7. Node-level resource contention
- Signature: Performance issues concentrated on specific nodes, noisy neighbors (batch jobs sharing nodes), node pressure events
- Effect: Fair sharing between pods breaks down under extreme contention
8. Memory pressure and GC storms
- Signature: Memory near limit, long GC pauses in application logs, OOMKill→restart→cold start loops
- Effect: Application becomes unresponsive during GC
9. DNS or networking saturation
- Signature: CoreDNS pod CPU at 100%, elevated DNS lookup failures, conntrack table full warnings
- Causes: Search domain amplification (ndots:5 multiplies lookups), connection tracking table exhaustion, load balancing issues with long-lived HTTP/2 connections pinning to old pods
10. Aggressive health probes creating death spiral
- Signature: Liveness probe failures during high load, healthy pods getting killed, restarts correlate with traffic spikes
- Effect: Killing busy pods concentrates load on survivors, making things worse
Investigation order: Check recent changes first, then events/restarts, then throttling, retries, and dependency saturation.
5. Immediate Stabilization
Choose actions based on evidence; prefer reversible changes:
Rollback if deployment-related:
kubectl rollout undo deployment/<name> -n <namespace>
Freeze further releases until root cause is confirmed.
Shed non-critical load:
- Enable rate limiting at ingress (return 429 quickly)
- Disable optional features via feature flags
- Pause batch jobs and cron tasks
Break retry amplification:
- Reduce retry attempts to 1 with exponential backoff and jitter
- Activate circuit breakers (Istio, Envoy outlier detection)
- Ensure client timeouts are shorter than server timeouts to cancel abandoned work
Stabilize autoscaling:
- Temporarily set HPA minReplicas to current peak to prevent scale-down
- Manually scale deployment and pre-warm capacity
kubectl scale deployment/<name> --replicas=50 -n <namespace>
Address CPU throttling:
- Raise or remove CPU limits (keep requests for scheduling); this requires pod restart
- Migrate to a larger pod CPU request/limit configuration
Fix health checks:
- Ensure liveness probes don't depend on external services
- Increase probe timeout and failure threshold to avoid killing pods under load
Protect databases:
- Implement connection pool limits and query timeouts in application
- Enable read-only mode or caching layers if database is overwhelmed
6. Long-Term Fixes
After restoring stability, address root causes:
- Capacity planning: Right-size resource requests/limits based on actual usage patterns; consider auto-tuning tools
- Load shedding: Build adaptive rate limiting and graceful degradation into services
- Retry discipline: Standardize retry policies (limited attempts, exponential backoff, jitter) and implement deadline propagation
- Scaling improvements: Use custom metrics for HPA that reflect actual service health, add stabilization windows, ensure readiness probes wait for warm-up
- Dependency resilience: Add circuit breakers, bulkheads, and fallback strategies for external dependencies
- Observability gaps: Instrument CPU throttling, retry counts, and connection pool metrics; create runbooks for common failure modes
- Chaos engineering: Test failure scenarios regularly (pod kills, resource constraints, dependency failures) to validate resilience
Common mistakes to avoid:
- Relying on average metrics when tail latency is the problem
- Ignoring CPU throttling because average utilization looks reasonable
- Over-aggressive autoscaling without stabilization periods
- Liveness probes that depend on downstream services
- Missing retry amplification in cascading failures
The key is methodical, evidence-driven diagnosis followed by both immediate tactical fixes and strategic improvements to prevent recurrence.