Debug Playbook: High latency and intermittent 503 errors on `/api/v1/orders` endpoint
Symptom: High latency (median > 500ms) and intermittent HTTP 503 Service Unavailable errors on the /api/v1/orders endpoint, affecting a subset of users. The issue appears to be intermittent and not always correlated with peak traffic.
System Architecture Context (Assumed/Provided): A microservice architecture running on Kubernetes. The /api/v1/orders endpoint is handled by the order-service which communicates with inventory-service and payment-service via gRPC. Data is stored in a shared PostgreSQL database. Monitoring is via Prometheus/Grafana and centralized logging via Loki.
---
Hypotheses & Diagnostic Steps:
Hypothesis 1: Resource exhaustion or misconfiguration on `order-service` pods.
- Description: The
order-service pods might be hitting CPU or memory limits, leading to throttling, restarts, or slow processing, manifesting as high latency and occasional failures when requests queue up. - Checks:
* Check 1: Review Kubernetes pod resource utilization. * Command/Step: kubectl top pod -n production | grep order-service * Expected Output/Indicator: CPU or Memory usage close to or exceeding configured limits (e.g., >80% CPU, >90% Memory). * Check 2: Check order-service pod restart history and events. * Command/Step: kubectl get pods -n production | grep order-service (note RESTARTS column) * Command/Step: kubectl describe pod <pod-name> -n production (look for Events related to OOMKilled or CrashLoopBackOff) * Expected Output/Indicator: Frequent restarts or recent OOMKilled events for order-service pods.
* Fix 1: Temporarily increase CPU/memory limits for order-service deployment. * Fix 2: Scale up the number of order-service replicas if resource utilization is high but not at limits.
Hypothesis 2: Upstream dependency service (e.g., `inventory-service` or `payment-service`) latency or errors.
- Description: The
order-service depends on inventory-service and payment-service. Latency or errors in these upstream gRPC calls could propagate to the order-service, causing its endpoint to respond slowly or fail. - Checks:
* Check 1: Review order-service logs for gRPC client errors or timeouts. * Command/Step: `logcli query '{kubernetes_app=