Daily CPU spike on an AWS production server: finding the real cause
CPU spiked at the same time every day. The obvious suspect, a cron job, was a red herring; targeted pidstat capture proved it was a security agent's filesystem scan.
- My role
- Root cause analysis and fix
- Period
- 2026
- Scale
- Production application server on AWS EC2
- Stack
- Bash, pidstat, cron, RHEL, AWS EC2
Context
The application team reported high CPU on a production server on AWS, recurring daily at about 11:28 a.m.
The problem, stated precisely
A predictable, time-based CPU spike on a production server, with no obvious owner and no visible cause in the usual monitoring views.
Investigation
First suspect: cron. I checked all cron jobs for root and the application account and found an application job scheduled at 11:25 a.m., three minutes before the spike. It was commented out as a test.
It wasn’t cron. The next day, the spike returned at 11:28 a.m. With the cron job disabled, that suspect was ruled out.
Capturing evidence instead of guessing. I wrote a script that watched CPU utilisation and, whenever it crossed 50%, captured pidstat output showing exactly which processes were consuming CPU at that moment.
Root cause. The next day’s capture showed the Nexus agent running several find scans of the filesystem at the same time.
Fix and rollout
I reduced the agent’s scanning load, sizing the find scans to the server’s vCPU count. After the change, CPU did not go above 40%.
This was reflected in entire Env where CPU was since abrupt increase at certain time.
What I learned
- Patience beats a quick fix: disabling the obvious suspect without proof would have hidden the real cause.
- When a problem recurs on a schedule, capture evidence at the moment it happens rather than reconstructing it later.