Production troubleshooting is not always about what appears most obvious on a monitoring dashboard. Sometimes, the most visible symptom is not the actual root cause.
While investigating a document-generation failure in a production Azure Kubernetes Service (AKS) environment, I discovered that what initially appeared to be a CPU and scheduling problem was actually a combination of memory exhaustion, database connection pool starvation, and overlapping background jobs.
1. Understanding the Problem
A production application responsible for generating insurance policy documents and statements was experiencing intermittent failures.
The application architecture consisted of:
- Azure Kubernetes Service (AKS)
- Two production pod replicas
- Node.js backend
- Puppeteer and Chromium for PDF generation
- Oracle database connection pools
- Multiple scheduled background jobs
- Argo CD for GitOps deployments
- Azure Monitor for observability
The initial investigation focused on CPU spikes, Kubernetes scheduling, deployment rollouts and node taints. However, a deeper investigation into resource utilisation, container termination events and application logs revealed a different story.
How the failure occurred
2. What the Monitoring Dashboard Revealed
Using Azure Monitor's Kubernetes compute resource dashboard, I observed the following:
| Metric | Observed value |
|---|---|
| CPU utilisation (requests) | 29.1% |
| CPU utilisation (limits) | 7.27% |
| Memory utilisation (requests) | 182% |
| Memory utilisation (limits) | 90.9% |
| Pod 1 memory usage | 1.92 GiB |
| Pod 2 memory usage | 1.72 GiB |
| Memory request per pod | 1 GiB |
| Memory limit per pod | 2 GiB |
The application was consuming almost twice its requested memory, while operating dangerously close to its configured memory limit.
CPU utilisation, on the other hand, was relatively low at the time of observation.
This shifted the investigation from CPU and scheduling towards memory management and application-level resource contention.
3. Root Cause One: OOMKilled During PDF Generation
Further investigation revealed that one of the production containers had already been terminated with:
Reason: OOMKilled
Exit Code: 137
The application used Puppeteer and Chromium to generate PDF documents. Chromium introduces significant memory overhead beyond the Node.js application heap.
When multiple PDF-generation requests and scheduled background jobs executed concurrently, memory consumption exceeded the container's configured 2 GiB limit.
The container was terminated, interrupting in-flight document-generation requests.
This explained one of the reasons users experienced intermittent document-generation failures.
4. Root Cause Two: Oracle Connection Pool Starvation
Application logs revealed another critical issue:
NJS-040: connection request timeout
Approximately 2,600 occurrences were observed within a 24-hour period.
The application was configured with an Oracle connection pool maximum of 10 connections per pod. However, several workloads were competing for database connections:
- Long-running background synchronisation jobs.
- Policy and customer data retrieval.
- Scheduled document-generation jobs.
- Concurrent API requests.
- Additional database connection pools within the application.
Some background jobs held database connections for extended periods, preventing other requests from acquiring available connections.
Consequently, document-generation workflows that depended on Oracle data could fail or time out before PDF generation even began.
5. The Hidden Problem: Duplicate Cron Execution
Another contributing factor was running application-level scheduled jobs across both Kubernetes replicas.
Without coordination or leader election, both replicas could execute the same scheduled workloads simultaneously.
This increased:
- Database connection contention.
- Memory consumption.
- Background processing overhead.
- Competition between API requests and scheduled workloads.
Horizontal scaling improves availability, but without proper workload coordination, it can also amplify existing application bottlenecks.
6. The Remediation Strategy
Immediate mitigation: Right-size memory resources
Based on observed memory consumption, the proposed Kubernetes resource configuration was:
resources:
requests:
cpu: "500m"
memory: "2Gi"
limits:
cpu: "2"
memory: "4Gi"
Increasing memory provides additional headroom for Chromium based PDF generation, subject to available cluster capacity and load testing.
However, increasing memory alone does not resolve database connection starvation or uncontrolled workload concurrency.
Application-level improvements
The longer-term remediation strategy includes:
- Separating PDF generation into a dedicated worker deployment.
- Limiting concurrent Chromium processes.
- Ensuring browser instances are properly closed after use.
- Reducing database connection hold times.
- Processing long-running background jobs in smaller batches.
- Consolidating database connection pools where appropriate.
- Implementing leader election or dedicated Kubernetes CronJobs with appropriate concurrency controls.
- Reviewing Oracle session capacity before increasing connection pool limits.
Proactive monitoring and alerting
To prevent recurrence, the proposed monitoring strategy includes alerts for:
- OOMKilled container events.
- Memory utilisation exceeding 85% of configured limits.
- Oracle NJS-040 connection timeout errors.
- Container restart frequency.
- Database connection acquisition latency.
- PDF-generation failure rates.
The objective is to detect resource pressure before it becomes a customer-facing incident.
7. Key Lessons Learned
This investigation reinforced several important principles in DevOps and Site Reliability Engineering:
- CPU spikes do not automatically indicate a CPU bottleneck.
- Kubernetes memory requests should reflect realistic workload consumption.
- Increasing resource limits is a mitigation, not necessarily a permanent solution.
- Scaling replicas without coordinating background jobs can amplify resource contention.
- Infrastructure metrics must be correlated with application logs and container lifecycle events.
- Effective observability should connect infrastructure behaviour to actual customer impact.
Conclusion
The most important outcome of this investigation was identifying the difference between infrastructure symptoms and application level failure mechanisms.
The evidence pointed to memory exhaustion and Oracle connection pool starvation, compounded by overlapping background workloads, rather than CPU utilisation or node scheduling alone.
As DevOps engineers, our responsibility goes beyond keeping pods running. We must understand how infrastructure, application behaviour, database dependencies and workload concurrency interact to deliver reliable services.
A healthy Kubernetes deployment does not necessarily mean a healthy application. Observability bridges that gap.
Monitor the symptoms. Investigate the dependencies. Fix the root cause.


Top comments (2)
Two things that often sit under this exact pattern with Puppeteer in a pod. The default /dev/shm in a container is 64 MB, so Chromium can stall or crash under load well before the memory limit; mounting an emptyDir with medium: Memory and a sizeLimit at /dev/shm, or launching with --disable-dev-shm-usage, removes that. And when Node runs as PID 1 it does not reap orphaned Chromium children, so a timed-out render can leave renderer processes that still count against the cgroup; an init such as tini, or shareProcessNamespace, fixes that. With a 1 GiB request and a 2 GiB limit the pod can also use memory the scheduler never reserved, so I would set the memory request equal to the limit and cap concurrent renders with a small queue, so scheduled jobs and requests cannot overlap.
This is where the difference made by duplicating the cron jobs shows up. Two replicas running the same sync job is not just a matter of doubled work, but also doubled connection hold time during the period when the PDF requests need a pool. In my opinion, one should separate the pools depending on the load before increasing the maximum number of connections, with small pool for API requests and capped pool for background jobs so that long sync process could queue against itself rather than blocking the document generation. Pool wait time for each workload should be the next parameter to check, since it tells you which side is actually hungry. Were the NJS-040 timeouts occurring within the periods of scheduled jobs, or were they spread during the day?