الملفات
ghaymah-exam-MostafaBebars-SRE/q2-postmortem/postmortem-report.md
2026-07-28 13:34:58 +03:00

4.4 KiB

Incident Postmortem Analysis: Application Outage (OOMKilled)

1. Summary

The application deployed on the Ghaymah platform experienced a complete outage lasting 45 minutes. The service continuously crashed and failed to start due to recurring OOMKilled (Out of Memory) errors. This resulted in a 100% failure rate for incoming requests during the incident window until mitigation measures were applied.

2. Timeline of Events

  • T-00:00 - Traffic Spike / Memory Leak Initiated: Application memory consumption begins to spike uncontrollably due to an anomalous load or internal memory leak.
  • T+00:05 - Initial OOMKilled Event: Container RAM usage hits the hard limit. The Ghaymah orchestrator forcefully terminates the process to protect the node, logging an OOMKilled event.
  • T+00:06 to T+00:44 - CrashLoopBackOff State: Ghaymah automatically attempts to restart the container, but it repeatedly exceeds memory limits shortly after booting. Service remains entirely unavailable.
  • T+00:45 - Incident Mitigated: Engineers manually intervene by vertically scaling the container's memory limits or deploying a hotfix. The application stabilizes and resumes serving traffic.

3. Root Cause

An OOMKilled error occurs when a container attempts to consume more memory than its configured limits allow. The underlying causes typically involve:

  • Memory Leak: A flaw in the application code where unused memory is not released (e.g., inefficient garbage collection, unclosed connections).
  • Unoptimized Queries/Payloads: The application attempted to process an unusually large dataset in memory all at once rather than using streams or pagination.
  • Under-provisioning: The application lacked the baseline memory required to handle a legitimate surge in concurrent user traffic.

4. Action Items & Recommendations

  • Code Profiling: Conduct memory profiling on the application to identify and patch memory leaks.
  • Pagination/Streaming: Ensure large data processing tasks use streams rather than loading entire datasets into RAM.
  • Capacity Tuning: Re-evaluate and adjust the baseline memory limits and requests configured for the container.
  • Implement Auto-scaling: Configure dynamic scaling policies to absorb sudden spikes automatically.

Auto-Scaling Policy Design for Ghaymah

Ghaymah natively supports both horizontal and vertical auto-scaling based on CPU and memory usage. To prevent this issue from recurring, a proactive scaling policy should be implemented:

  • Target Metric: Average Container Memory Utilization.
  • Scale-Out (Increase Capacity):
    • Condition: If Memory Utilization is greater than 75% for a sustained period of 2 minutes.
    • Action: Add 1 additional container replica (Horizontal Scaling) or dynamically increase the RAM allocation (Vertical Scaling).
  • Scale-In (Decrease Capacity):
    • Condition: If Memory Utilization falls below 40% for 5 minutes.
    • Action: Remove 1 replica to optimize resource consumption.
  • Limits: Minimum of 2 replicas (for high availability) and a Maximum of 10 replicas (to control cloud spend).

Why this works: The 75% threshold leaves a 25% safety buffer. This gives the Ghaymah platform enough time to spin up new instances and distribute the load before any single container hits the 100% OOMKilled threshold.


Early Detection Using Ghaymah Monitoring Tools

Relying on user complaints or complete downtime is an anti-pattern. You can detect memory exhaustion early using Ghaymah's built-in monitoring:

  • Threshold Alerts: Configure Ghaymah to send automated alerts (via Slack, email, or webhook) when memory usage reaches 70% and 80%. This provides a critical window for intervention before the container crashes.
  • Restart Rate Monitoring: Set an alert if the container restart count exceeds 1 within a 15-minute window. Frequent restarts are the earliest indicator of a CrashLoopBackOff state.
  • Application Logs Analysis: Monitor logs for warning signs such as garbage collection (GC) taking excessively long, or application-level out-of-memory warnings that often precede the infrastructure-level kill signal.
  • Endpoint Health Checks: Ensure proper Liveness and Readiness probes are configured. If high memory pressure degrades application performance, the Readiness probe should fail, instructing Ghaymah's load balancer to stop routing traffic to the struggling instance before it dies.