Fix High admin-ajax.php CPU Usage in WordPress: Runbook

Diagnostic runbook to fix high admin-ajax.php CPU usage in WordPress. Profile AJAX calls, disable WooCommerce cart fragments, and tune Heartbeat API.

Fix High admin-ajax.php CPU Usage in WordPress: Runbook
Immediate Performance Fix

To fix high admin-ajax.php CPU usage in WordPress: Identify rogue actions via the browser Network tab (XHR filter), dequeue WooCommerce's cart fragments script on non-shop pages using wp_dequeue_script('wc-cart-fragments'), throttle the Heartbeat API interval to 120s via heartbeat_settings filter, and replace virtual WP-Cron with a system crontab job.[1]

Follow this step-by-step diagnostic runbook to inspect server access logs, implement Redis object caching for AJAX transients, and configure Cloudflare rate limiting against automated AJAX scrapers.[2]


Technical Architecture of WordPress admin-ajax.php

In the WordPress runtime environment, admin-ajax.php serves as the centralized endpoint for asynchronous client-to-server HTTP requests.[1] While designed primarily for administrative tasks inside wp-admin (such as draft autosaves and revision lockouts), third-party theme and plugin developers widely repurpose admin-ajax.php for frontend interactive features, including live search filtering, mini-cart updates, and wishlists.[3]

What Causes High CPU Usage from admin-ajax.php in WordPress?

Unlike static asset requests, every single call to admin-ajax.php executes a full WordPress application bootstrap.[1]

When a browser initiates an AJAX request:

  1. Nginx or LiteSpeed invokes PHP-FPM or LSPHP.
  2. PHP loads wp-load.php, initializing core constants, database abstractions, active themes, and all installed plugins.
  3. WordPress sets up the database connection and registers all active hooks (init, wp_loaded).
  4. The requested action hook is fired (wp_ajax_<action> for authenticated users or wp_ajax_nopriv_<action> for public visitors).
  5. The output is buffered, encoded into JSON, and returned to the client.

Because full caching plugins (like WP Rocket or LiteSpeed Cache) intentionally bypass dynamic POST and GET requests sent to admin-ajax.php, high-concurrency traffic directly hammers server CPU cores and exhausts database connection pools.[4]


Diagnostic Matrix: Primary admin-ajax.php Culprits and Resource Impact

Use this matrix to identify common offenders and target the appropriate remediation layer:

AJAX Trigger Subsystem Default Execution Frequency Server Resource Impact Primary Culprit Component Production Remediation Action
WooCommerce Cart Fragments On every frontend page load for all users High CPU + Database read queries per visitor wc-cart-fragments.js calling get_refreshed_fragments Dequeue script on non-shop pages; adopt LocalStorage mini-cart
WordPress Heartbeat API Every 15 seconds in post editor, 60s in admin Sustained background CPU load across active tabs heartbeat.js executing wp_autosave and post locks Throttle frequency to 120s or disable on frontend via PHP filter
Live Search & Auto-Suggest On every keyboard keystroke in search bar Severe MySQL CPU spikes; unindexed full-text scans Theme AJAX search widgets Implement Redis object caching and debounced input delays (300ms+)
Virtual WP-Cron Execution Randomly triggered by frontend visitor page hits Process pile-ups and PHP worker starvation wp-cron.php running via background AJAX ping Set DISABLE_WP_CRON=true; schedule real system crontab
External Scrapers & Botnets Rapid automated GET/POST request floods 100% CPU lock; server crashes (502/504 Bad Gateway) Rogue web crawlers scanning /wp-admin/admin-ajax.php Enforce Cloudflare WAF Managed Challenge on unauthenticated AJAX

How Do I Find Which Plugin Is Calling admin-ajax.php?

Before modifying configuration files, isolate the specific action string dominating your server’s request queue.[3]

Step 1: Profiling via Browser Network Tools (Fetch/XHR)

  1. Open your website in Google Chrome, Microsoft Edge, or Mozilla Firefox.
  2. Press F12 (or right-click and select Inspect) to open Developer Tools.
  3. Select the Network tab.
  4. Click the Fetch/XHR filter button to eliminate CSS, JS, and image assets from the log.
  5. Reload the page and observe incoming requests:
    • Look for entries named admin-ajax.php or ?wc-ajax=....
    • Click on the request and open the Payload (or Headers) tab.
    • Inspect the action parameter (e.g., action: wc_get_refreshed_fragments, action: heartbeat, or action: live_search).
    • The action name directly reveals the parent plugin or theme module executing the background query.[1]

Step 2: Auditing Server Access Logs via Terminal

If the CPU spikes originate from external bots or background visitors, inspect your live web server access logs via SSH:

# Extract the top 10 most frequent admin-ajax actions from Nginx or LiteSpeed access logs
grep "admin-ajax.php" /var/log/nginx/access.log | awk '{print $7}' | cut -d'?' -f2 | sort | uniq -c | sort -nr | head -n 10

For cPanel and CloudLinux environments:

grep "admin-ajax.php" /usr/local/apache/domlogs/yourdomain.com | awk -F'action=' '{print $2}' | awk '{print $1}' | sort | uniq -c | sort -nr | head -n 10

Does WooCommerce Cart Fragments Cause High admin-ajax CPU Spikes?

Yes, WooCommerce cart fragments (wc-ajax=get_refreshed_fragments) is the single most prevalent cause of high CPU utilization on e-commerce WordPress websites.[5]

By default, WooCommerce loads wc-cart-fragments.js across every page of your website (including homepage, blog posts, contact pages, and landing pages). This script sends an AJAX request on page load to update the item counter and subtotal in the header mini-cart.

Because this request verifies session cookies, page-level caching cannot cache it. On a store receiving 10,000 page views per day, this script triggers 10,000 unnecessary dynamic PHP and database queries, crashing shared hosting environments and inflating Time to First Byte (TTFB).[4]

Step 3: Dequeuing Cart Fragments on Non-Shop Pages via functions.php

Add the following optimized snippet to your child theme’s functions.php file or via a site-specific code snippets plugin:

/**
 * Dequeue WooCommerce Cart Fragments on Non-Shop Pages to Eliminate High CPU Spikes
 */
add_action( 'wp_enqueue_scripts', function() {
    // Only allow cart fragments on actual WooCommerce store pages
    if ( function_exists( 'is_woocommerce' ) ) {
        if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() && ! is_page( 'shop' ) ) {
            wp_dequeue_script( 'wc-cart-fragments' );
        }
    }
}, 99 );

Modern Architecture: Replacing AJAX Cart with HTML5 LocalStorage

Modern WooCommerce stores (v7.8+) can utilize client-side JavaScript to store mini-cart items inside the browser’s localStorage. This updates the mini-cart instantly upon adding an item without polling the server on subsequent page visits.[5]

Operational Pro-Tip: Full Page Cache Validation

Once wc-cart-fragments is dequeued on informational and blog pages, check your response headers (X-Cache: HIT or X-LiteSpeed-Cache: hit). Static and blog URLs will now serve entirely from memory in under 50 milliseconds without invoking PHP or MySQL.


How Do You Disable or Throttle the WordPress Heartbeat API?

The WordPress Heartbeat API maintains communication between the web browser and the server. It provides real-time notifications, saves post revisions automatically, and warns you if another administrator is editing the same post.[1]

However, leaving multiple WordPress admin tabs open results in dozens of simultaneous requests hitting admin-ajax.php every 15 seconds.

Step 4: Throttling Heartbeat Frequency via PHP Code

Add this filter to functions.php to throttle the Heartbeat API frequency from 15 seconds to 120 seconds in the administrative dashboard, while disabling it completely on the public frontend:

/**
 * Throttle and Optimize WordPress Heartbeat API Frequency
 */
add_filter( 'heartbeat_settings', function( $settings ) {
    // Extend polling interval to 120 seconds (default is 15s - 60s)
    $settings['interval'] = 120;
    return $settings;
} );

// Disable Heartbeat completely on frontend pages
add_action( 'init', function() {
    if ( ! is_admin() ) {
        wp_deregister_script( 'heartbeat' );
    }
}, 1 );
Architectural Pitfall: Disabling Heartbeat in wp-admin

Never disable Heartbeat entirely within wp-admin. Disabling it breaks automatic post draft saves, revision history tracking, e-commerce order notification alerts, and lockouts when multiple authors collaborate on the same article.


Offloading Background Tasks: System Cron and Redis Object Cache

To maintain high responsiveness under intense transaction loads:

Step 5: Replace Virtual WP-Cron with a Linux System Crontab

Virtual WP-Cron runs during frontend page requests, frequently compounding AJAX CPU starvation.[4]

  1. Open wp-config.php and disable the virtual runner:
    define( 'DISABLE_WP_CRON', true );
  2. Open your server crontab via SSH (crontab -e) and configure a real cron execution every 10 minutes:
    */10 * * * * /usr/bin/php -q /home/username/public_html/wp-cron.php >/dev/null 2>&1

Step 6: Deploy Redis Object Caching for Transient Lookups

AJAX requests repeatedly query the wp_options table for transients and site settings. By routing these read operations to an in-memory Redis key-value store, database query times drop from 25ms to under 1ms.[2]

High-traffic stores requiring dedicated bare-metal database instances and sub-millisecond memory performance can deploy on Dedicated Servers in Pakistan or explore global enterprise clusters via Enterprise Dedicated Servers.


Rate Limiting Malicious AJAX Spammers via Cloudflare WAF

Automated bots frequently target admin-ajax.php to exploit unpatched plugin vulnerabilities or scrape product pricing.

Create a Cloudflare WAF Custom Rule to enforce rate limiting:

  1. Log in to your Cloudflare Dashboard and navigate to Security > WAF > Rate Limiting Rules.
  2. Define the rule criteria:
    • Field: URI Path
    • Operator: contains
    • Value: /wp-admin/admin-ajax.php
  3. Set the rate limit threshold:
    • Requests: Greater than 30 requests per 10 seconds.
    • Action: Managed Challenge (or Block).

This configuration protects backend PHP-FPM workers while permitting legitimate frontend user interactions.


Production Verification Checklist

Execute this checklist before closing your performance tuning workflow:

  • Network Profiling Completed: Inspected Fetch/XHR filter in DevTools to confirm no rogue AJAX loops.
  • WooCommerce Cart Fragments Dequeued: Verified wc-cart-fragments.js is absent on blog and homepage URLs.
  • Heartbeat Throttled: Confirmed heartbeat.js interval is extended to 120s in post editor.
  • System Cron Configured: Verified DISABLE_WP_CRON=true is defined in wp-config.php.
  • Redis Object Cache Active: Confirmed memory cache hit ratio exceeds 95% via redis-cli info stats.
  • WAF Rate Limiting Active: Enforced challenge rules on high-frequency unauthenticated AJAX endpoints.

Supercharge Your WordPress & WooCommerce Hosting with NextGen

Tired of high CPU alerts, slow database queries, and server throttling? NextGen provides enterprise NVMe VPS and dedicated servers with pre-configured Redis caching and LiteSpeed performance optimization.

Explore Enterprise Dedicated Servers

Disclaimer: This post is for informational and educational purposes only, accurate to the best of our knowledge at publication. It does not constitute advice. We do not guarantee accuracy or completeness and accept no liability for any decisions or losses resulting from reliance on this content.

Sources & Official References
  1. WordPress Developer Handbook. "AJAX in Plugins and the admin-ajax.php Processing Flow." Official Core Reference. Retrieved November 2026. https://developer.wordpress.org/plugins/javascript/ajax/
  2. WordPress Core Documentation. "Heartbeat API Specification and Filter Hooks." Retrieved November 2026. https://developer.wordpress.org/reference/hooks/heartbeat_settings/
  3. Google Chrome Developers. "Inspect Network Activity and Monitor XHR/Fetch Requests." Chrome DevTools Documentation. Retrieved November 2026. https://developer.chrome.com/docs/devtools/network/
  4. Google Cloud Architecture Center. "High-Performance WordPress on Compute Engine: Mitigating Dynamic Request Bottlenecks." Retrieved November 2026. https://cloud.google.com/solutions/architecture/wordpress-on-gcp
  5. WooCommerce Core Documentation. "Cart Fragments Script and Mini-Cart Performance Optimization." Retrieved November 2026. https://developer.woocommerce.com/

Disclaimer: This post is for informational and educational purposes only, accurate to the best of our knowledge at publication. It does not constitute advice. We do not guarantee accuracy or completeness and accept no liability for any decisions or losses resulting from reliance on this content.