Skip to main content
KadiCache
Engineering Journal · Architecture9 min read1,873 wordsVerified 2026-11-23

Fix WordPress High CPU From admin-ajax & wp-cron

Stop 100% WordPress high CPU spikes from admin-ajax.php Heartbeat polling, wp-cron stampedes, xmlrpc.php, and uncached bots.

WordPress server processor cooling from 100% admin-ajax CPU overload down to 12% CPU
0.000 Layout Shift10 Sections✓ Verified
⚡ Executive Summary · 30-Second Spec100% Code-Verified
WP Admin Path
WP Admin -> KadiCache -> Bloat Removal + Cache + Preload
Measured Impact
70%–92% drop in PHP-FPM CPU load · Zero wp-cron stampedes
DevTools Proof Marker
window.wp.heartbeat stub | DISABLE_WP_CRON | X-KadiCache: HIT
  • When htop shows PHP-FPM pegging all cores at 100%, guessing blindly wastes hours—a 15-second access-log frequency tally immediately reveals whether the culprit is admin-ajax.php, wp-cron.php, xmlrpc.php, or query-string cache busting.
  • Deregistering heartbeat naively throws fatal JavaScript TypeError crashes in plugins expecting window.wp.heartbeat; KadiCache injects a safe no-op JS stub while preserving post-lock protection inside the Gutenberg/Classic post editor.
  • Moving wp-cron.php out of visitor HTTP loopback requests into a flock-guarded 1-minute system crontab eliminates lock contention during traffic spikes.
Table of Contents (10 sections)

Diagnosing WordPress high CPU emergencies starts with one rule: read your access log before upgrading your VPS. Over 90% of 100% CPU incidents on WordPress and WooCommerce servers come from four repeatable loops: /wp-admin/admin-ajax.php polling, /wp-cron.php loopback storms, uncached query-string floods, and /xmlrpc.php brute-force bursts.

Step 1: Run This 15-Second SSH Triage Before Changing Anything#

Open an SSH session during (or right after) a CPU spike and run these four read-only commands to pinpoint the exact URI, IP address, or PHP function burning your cores:

BASH
# 1. Top 15 most-requested WordPress endpoints (stripping query strings)
tail -n 20000 /var/log/nginx/access.log | awk '{print $7}' | cut -d'?' -f1 | sort | uniq -c | sort -rn | head -15

# 2. Top 15 full URIs WITH query strings (exposes ?wc-ajax=, ?fbclid=, ?s= search spam)
tail -n 20000 /var/log/nginx/access.log | awk '{print $7}' | sort | uniq -c | sort -rn | head -15

# 3. Top 10 User-Agents hitting uncached endpoints (exposes runaway AI/SEO crawlers)
tail -n 20000 /var/log/nginx/access.log | awk -F'"' '{print $6}' | sort | uniq -c | sort -rn | head -10

# 4. Check PHP-FPM worker memory footprint and active process states
ps -ylC php-fpm8.3 --sort:rss | tail -n 15

Match your top result against this diagnostic matrix before flipping any switch:

Top Endpoint in Access LogTypical Spike RateUnderlying Root CausePermanent Engineering Fix
/wp-admin/admin-ajax.php40 – 350 POST/minIdle staff browser tabs firing action=heartbeat, or front-end AJAX counters/popups3-zone Heartbeat control (HeartbeatControl.php) + audit front-end AJAX
/wp-cron.phpOverlapping bursts on page hitsHTTP loopback pseudo-cron colliding with long WooCommerce / Action Scheduler jobsDISABLE_WP_CRON in wp-config.php + flock system crontab
/?fbclid=... or /?s=...150 – 3,000 GET/minUncached ad query strings, internal search spam (/?s=), or AI scraper botsEarly Drop-In marketing param ignore + Cloudflare WAF / Bot rules
/xmlrpc.php300 – 8,000 POST/minsystem.multicall brute-force bots booting full WordPress per POSTBlock /xmlrpc.php at Nginx/Cloudflare + KadiCache Bloat Removal

Enabling the PHP-FPM slowlog When Access Logs Look Quiet#

What if request volume is low (only 8 requests/minute), yet 4 php-fpm children sit at 99% CPU for 25 seconds each? That points to a hung outbound wp_remote_get() HTTP call without a timeout or an unindexed wp_postmeta LIKE '%value%' SQL scan. Enable request_slowlog_timeout = 5s and slowlog = /var/log/php8.3-fpm.slow.log in your PHP-FPM pool config for ten minutes: PHP will dump the exact file and line number of the offending plugin stack trace.

Culprit 1: The WordPress Heartbeat API Multiplication Effect#

A single logged-in browser tab polling /wp-admin/admin-ajax.php (action=heartbeat) once every 60 seconds looks harmless on staging. Now do the production math for a real WooCommerce store or editorial newsroom: 7 team members keep 8 WordPress tabs open each across dual monitors (Orders, Products, Coupons, Media Library, Analytics, Post Editor) = 56 open browser tabs.

At 15-second intervals, those 56 background tabs generate 224 uncached POST requests per minute—13,440 full WordPress + MySQL bootstraps every single hour! Because admin-ajax.php is an authenticated POST inside /wp-admin/, no page cache or CDN can cache it. Even worse, certain page builders, social-proof popups, and auction plugins enqueue heartbeat.min.js on the public frontend for every anonymous visitor.

FIG 01Trim unused WordPress front-end scripts and tune Heartbeat API intervals across Front end, Admin, and Post Editor.Zoom 2x

Why KadiCache's HeartbeatControl.php Injects a Safe Stub Instead of Blind Deregistration#

Paste a naive wp_deregister_script('heartbeat') snippet from a blog post into functions.php and two ugly regressions surface within 24 hours:

  1. Lost Editor Post Locks & Autosaves: Inside post.php (Gutenberg and Classic Editor), WordPress relies on Heartbeat to refresh _edit_lock (wp_check_post_lock()) and autosave drafts. Killing Heartbeat inside the editor lets two writers silently overwrite each other's articles.
  1. Broken $deps Chains & TypeError Crashes: Admin plugins that declare ['jquery', 'heartbeat'] in wp_enqueue_script() either fail to load at all or crash with Uncaught TypeError: Cannot read properties of undefined (reading 'connectNow') when calling window.wp.heartbeat.

Look at how Optimization/HeartbeatControl.php in KadiCache Free Core eliminates both failure modes:

  • Three Independent Zones (frontend, admin, editor): HeartbeatControl::context() detects get_current_screen()->base === 'post' (and even re-localizes heartbeatSettings on current_screen if WordPress core localized heartbeat early during admin_init). You can set Frontend = Off, Admin Dashboard = Off or Reduce (60s), and Post Editor = Reduce (60s)—cutting admin-ajax.php Heartbeat traffic by 80%–95% without sacrificing editor safety.
  • Dependency Graph Rewiring + Inline Compatibility Shim: Whenever Heartbeat is turned off on frontend or admin, HeartbeatControl::disable() walks $scripts->queue, removes 'heartbeat' from dependent $item->deps (preserving 'jquery'), and prepends a tiny no-op window.wp.heartbeat stub (connectNow, interval, enqueue, isQueued, getQueuedItem) so dependent scripts execute cleanly with zero console errors.

Culprit 2: Replacing wp-cron.php Loopback Storms With flock System Cron#

WordPress's default pseudo-cron (wp-includes/cron.php) fires inside visitor page requests: whenever scheduled timestamps are due, WordPress opens an internal HTTP/HTTPS socket back to https://example.com/wp-cron.php?doing_wp_cron=<microtime>.

On busy WooCommerce stores, pseudo-cron triggers WordPress high CPU in two opposite ways:

  • During Uncached Bursts: Twenty concurrent bots hit uncached URLs at 12:00:01 while WooCommerce Subscriptions, Action Scheduler, and sitemap rebuilds are due—spawning multiple overlapping loopback php-fpm processes that compete for PHP-FPM slots and wp_options cron row updates.
  • After Enabling Page Caching: Once Early Delivery serves 98% of anonymous traffic from advanced-cache.php before WordPress boots, wp-cron.php stops receiving regular visitor triggers. Then one editor logs in and inadvertently triggers 400 overdue tasks in a single spike!

Decouple background scheduling from web traffic permanently in two steps:

PHP
// Step 1: Add to wp-config.php (above "That's all, stop editing!")
define('DISABLE_WP_CRON', true);
BASH
# Step 2: Run due cron events every minute via OS crontab with flock mutual exclusion
* * * * * /usr/bin/flock -n /tmp/wp-cron-site1.lock /usr/local/bin/wp cron event run --due-now --path=/var/www/html >/dev/null 2>&1

Why use /usr/bin/flock -n + wp cron event run --due-now instead of wget -q -O - https://example.com/wp-cron.php? Three reasons:

  1. Zero Web Pool Starvation: CLI PHP runs outside php-fpm's pm.max_children limit and ignores Nginx 60s fastcgi_read_timeout ceilings.
  1. Guaranteed Single-Instance Lock: If a heavy WooCommerce Action Scheduler batch takes 95 seconds, flock -n skips the 12:01 overlapping spawn cleanly instead of piling up duplicate workers.
  1. Instant Visibility: You can inspect slow hooks anytime via wp cron event list without guessing.

Culprit 3: Query-String Cache Busting, Thundering Herds & Preload Locks#

Even after fixing Heartbeat and wp-cron, external traffic spikes can still hammer PHP-FPM if your cache policy leaves three doors open:

  1. Ad-Campaign Query Strings (?fbclid=, ?gclid=, ?msclkid=, ?ttclid=, ?utm_*): Every click from Facebook, Instagram, Google Ads, or TikTok appends a unique click identifier. Inside Cache/Delivery/Early/EarlyRequestServer.php, KadiCache strips marketing tracking parameters from the internal cache key while keeping the full URL intact in the visitor's browser so GA4 and Meta Pixel attribution still record 100% accurately—serving all 10,000 ad clicks from a single 4.4 ms Early HTML HIT.
  1. Post-Publish Cache Stampedes (60-Second Soft Purge): Deleting cached files immediately when an editor updates the homepage on a busy news site sends 50 simultaneous readers straight into MySQL. KadiCache serves a nonce-verified STALE snapshot for up to 60 seconds (NonceDetector.php) while a single background worker regenerates fresh HTML.
  1. Serialized Warmup Pacing (Preload/PreloadWorkerLock.php): Never let a cache preloader DDOS your own 2-vCPU VPS. KadiCache enforces strict single-worker locking and paced loopback requests so background warmup yields gracefully to live traffic.
FIG 02Page caching, pre-WordPress Early Delivery drop-in, nonce-safe TTL presets, and browser cache headers.Zoom 2x

Culprit 4: Blocking xmlrpc.php, /?s= Search Spam & Runaway AI Crawlers#

Finally, inspect whether bots are bypassing your cache intentionally:

  • Disable xmlrpc.php (Optimization/WordPressCleanup.php + Edge Rule): Attackers love POST /xmlrpc.php because a single system.multicall payload tests 500 passwords inside one PHP execution. Strip RSD/XML-RPC headers in WP Admin -> KadiCache -> Bloat Removal and return 403 at Nginx or Cloudflare WAF unless you actively use the Jetpack bridge.
  • Tame AI & SEO Crawler Floods: Inside WP Admin -> KadiCache -> Cloudflare -> Security & AI Bots (see our Cloudflare 5-Tab guide), toggle AI Bots Protection and WordPress WAF Rules so unthrottled scrapers are blocked at Cloudflare's edge before touching your origin.

5-Minute Post-Remediation Verification#

Re-run your SSH checks five minutes after applying these fixes:

  1. Confirm grep "admin-ajax.php" /var/log/nginx/access.log | tail -n 100 drops by 80%–95%.
  1. Confirm curl -sI "https://example.com/?fbclid=IwAR12345&utm_source=ig" returns X-KadiCache: HIT and Server-Timing: kc;desc="early_hit".
  1. Confirm htop load average settles below 0.4 × vCPU count with zero wp-cron.php loopback spikes.

Right-Sizing PHP-FPM pm.max_children So CPU Spikes Never Trigger OOM Kills#

Even after taming admin-ajax.php, wp-cron.php, and bot floods, misconfigured PHP-FPM process pools routinely turn a brief traffic burst into a total server freeze (Out of Memory kernel killer terminating mysqld!).

Calculate your server's true safe pm.max_children ceiling using real resident memory (RSS) rather than guesswork:

BASH
# Measure average resident RAM (in MB) per active php-fpm worker on your server
ps --no-headers -o "rss,cmd" -C php-fpm8.3 | awk '{ sum+=$1 } END { printf ("Avg Worker RAM: %d MB\n", sum/NR/1024) }'

Use this formula to size /etc/php/8.3/fpm/pool.d/www.conf cleanly:

Safe pm.max_children = (Total Server RAM - OS Reserve - MySQL Buffer Pool - Valkey RAM) ÷ Avg PHP Worker RAM

VPS TierTotal RAMReserved for OS + MySQL + ValkeyRemaining for PHP-FPMAvg WooCommerce Worker (85 MB)Safe pm.max_childrenRecommended pm Mode
2 GB VPS (1–2 vCPU)2,048 MB1,100 MB948 MB~85 MB10 – 11dynamic or ondemand
4 GB VPS (2 vCPU)4,096 MB1,850 MB2,246 MB~85 MB24 – 26dynamic
8 GB VPS (4 vCPU)8,192 MB3,400 MB4,792 MB~90 MB50 – 52dynamic or static
16 GB Dedicated (8 vCPU)16,384 MB6,400 MB9,984 MB~95 MB100 – 105static

Why does pairing a right-sized PHP-FPM pool with KadiCache's Early PHP Drop-In transform server stability? Because an Early Cache HIT inside advanced-cache.php finishes in 4.4 ms using < 4 MB of memory instead of holding an 85 MB WooCommerce worker for 450 ms. That single 100x reduction in worker occupancy allows a modest 4 GB VPS (25 PHP-FPM children) to absorb 3,500+ requests per second without breaking a sweat.

Stopping Uncached Internal Search Spam (/?s=...) at the Edge#

One final sneaky WordPress high CPU vector deserves special mention: automated SEO spam bots requesting millions of random internal search URLs (/?s=cheap+crypto+... or /search/random-phrase/). Because WordPress marks is_search() non-cacheable or runs unindexed LIKE '%term%' full-table scans across wp_posts.post_content, 60 search requests per minute can peg MySQL CPU at 100%.

Apply two layers of defense immediately:

  1. Cloudflare Rate Limiting / Challenge Rule: Challenge or rate-limit requests matching (http.request.uri.query contains "s=") or (http.request.uri.path contains "/search/") exceeding 10 requests per minute per IP.
  1. Persistent Object Cache (ObjectCacheEngine.php): Ensure KadiCache Object Cache is active so repeated option, taxonomy, and widget queries surrounding search templates resolve from RAM in sub-millisecond time.

Frequently Asked Engineering Questions

If I turn Heartbeat completely off in WP Admin, will two editors overwrite each other posts?
They would if a plugin disabled Heartbeat globally across post.php! Look at HeartbeatControl::context() in KadiCache: it explicitly separates editor (screen->base === post) from general admin dashboards and frontend pages, never force-deregistering Heartbeat inside an open post editor.
Why does wp-cron.php cause high CPU even when human traffic is moderate?
By default, WordPress checks the cron option on public page loads and spawns an HTTP loopback POST to /wp-cron.php?doing_wp_cron. Under bursty bot traffic or slow WooCommerce webhooks, multiple overlapping PHP workers wake simultaneously and compete for database locks.
Why do ad clicks (?fbclid, ?gclid, ?utm_source) sometimes spike origin CPU to 100%?
If your cache layer treats every unique fbclid query parameter as a separate uncached URL, 2,000 clicks from a Meta or TikTok ad campaign trigger 2,000 cold PHP + MySQL renders. KadiCache ignores marketing tracking parameters automatically so all 2,000 ad clicks hit the same warm Early HTML snapshot.
Can aggressive cache preloading itself cause 100% CPU on small 1-vCPU or 2-vCPU VPS servers?
Yes, if a preloader fires 10 parallel crawlers with no lock discipline. KadiCache PreloadWorkerLock.php serializes warmup batches with bounded concurrency and cooldown pacing so origin CPU stays calm.
Verified WordPress Architecture · Architecture
Apply these exact optimizations on your WordPress or WooCommerce site in 2 minutes.
E-E-A-T Source Verified

Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.

Optimization/HeartbeatControl.phpOptimization/WordPressCleanup.phpCache/Delivery/Early/EarlyRequestServer.phpPreload/PreloadWorkerLock.php
Connected Topical Cluster · Continue Deepening Your Setup