How to Reduce Server CPU Load by Optimizing the WordPress Heartbeat API

XeroWP Jul 7, 2026 6 min read
How to Reduce Server CPU Load by Optimizing the WordPress Heartbeat API

Introduction

Imagine you are monitoring your WordPress site's performance and notice that even during periods of low traffic, your server CPU usage is spiking. You check your logs and see a recurring request to a file called admin-ajax.php. These requests are frequent, persistent, and seem to happen even when you aren't actively doing much on the site. Welcome to the world of the WordPress Heartbeat API.

While the Heartbeat API provides essential real-time features, it is often a silent performance killer. For sites hosted on environments with limited resources or those scaling rapidly, an unoptimized Heartbeat can lead to site slowdowns, 504 Gateway Timeout errors, and unnecessary hosting costs. In this guide, we will dive deep into what the Heartbeat API does, why it drains your resources, and how you can optimize it to keep your XeroWP-hosted site running lean and fast.

What is the WordPress Heartbeat API?

Introduced in WordPress 3.6, the Heartbeat API allows WordPress to communicate between the web browser and the server in real-time. It uses a polling technique where the browser sends a request to the server every 15 to 60 seconds. The server then responds with data, allowing the dashboard to update dynamically without a full page refresh.

Key Functions of the Heartbeat API:

  • Autosaving Posts: It ensures your content is saved periodically while you write, preventing data loss if your browser crashes.
  • Post Locking: If you have a multi-author site, it notifies you if another user is currently editing the post you are trying to open.
  • Real-time Notifications: It allows plugins to display live notifications, such as e-commerce sales alerts or updated plugin statuses.
  • Session Management: It helps manage user sessions and login expirations.

The Performance Impact: Why Heartbeat Drains CPU

Every time the Heartbeat API "pulses," it sends an AJAX request to admin-ajax.php. To the server, this isn't just a simple text request; it is a full WordPress execution cycle.

When a pulse occurs:

  1. The server receives the POST request.
  2. PHP must boot up.
  3. The entire WordPress core must load.
  4. All your active plugins and your theme must initialize.
  5. The database is queried to check for updates or locks.

If you have the WordPress dashboard open in multiple tabs, each tab sends its own pulses. If you have five tabs open, and each pulses every 15 seconds, that is 20 full WordPress executions per minute—just from one user. On a shared or resource-constrained environment, this can quickly exhaust the available CPU cycles, leading to a sluggish experience for your actual site visitors.

How to Diagnose Heartbeat Issues

Before you start disabling features, you need to confirm that the Heartbeat API is actually the cause of your high CPU usage.

Using Chrome DevTools

  1. Open your WordPress dashboard.
  2. Right-click and select Inspect, then go to the Network tab.
  3. In the filter box, type admin-ajax.php.
  4. Watch the list. You will see a new request appear every 15 or 60 seconds.
  5. Click on a request and look at the "Time" column. If these requests are taking a long time to process (e.g., over 500ms), they are consuming significant server resources.

Checking Server Logs

If you have access to your access logs (which we provide via the XeroWP dashboard), look for frequent POST requests to /wp-admin/admin-ajax.php. A high volume of these relative to your total traffic is a red flag.

Method 1: Optimizing with the Heartbeat Control Plugin

For most users, the easiest way to manage this is with the Heartbeat Control plugin by WP Rocket. It provides a simple graphical interface to limit or disable the API in specific areas of your site.

Steps to Configure:

  1. Install and activate the Heartbeat Control plugin from the WordPress repository.
  2. Navigate to Settings > Heartbeat Control.
  3. You will see three sections: WordPress Dashboard, Frontend, and Post Editor.

Recommended Settings:

  • Frontend: Choose "Disable Heartbeat." Most sites do not need the Heartbeat API running on the public-facing side of the site unless you use specific live-tracking plugins.
  • WordPress Dashboard: Choose "Modify Heartbeat" and set the frequency to 60 or 120 seconds. This reduces the frequency of update checks while keeping the dashboard functional.
  • Post Editor: Choose "Modify Heartbeat" and set it to 60 seconds. This ensures autosaves still happen but at a frequency that is less taxing on the server.

Method 2: Optimizing with Code (The Developer Way)

If you prefer not to add another plugin to your site, you can manage the Heartbeat API using code snippets in your theme's functions.php file or a site-specific plugin.

Disabling Heartbeat Everywhere

If you want to completely shut it down (note: this will disable autosaves and post locking), use this snippet:

add_action('init', 'stop_heartbeat', 1);
function stop_heartbeat() {
    wp_deregister_script('heartbeat');
}

Slowing Down the Heartbeat Frequency

Instead of disabling it, you can change the interval. The following code changes the pulse to every 60 seconds:

function xero_slow_heartbeat( $settings ) {
    $settings['interval'] = 60; // Time in seconds
    return $settings;
}
add_filter( 'heartbeat_settings', 'xero_slow_heartbeat' );

Disabling Heartbeat on the Frontend Only

This is often the best balance for performance. It keeps the API active for editors but removes the load from visitors.

add_action( 'init', 'xero_disable_frontend_heartbeat', 1 );
function xero_disable_frontend_heartbeat() {
    if ( ! is_admin() ) {
        wp_deregister_script( 'heartbeat' );
    }
}

Best Practices for Different Environments

For E-commerce Sites (WooCommerce)

WooCommerce often uses AJAX for cart fragments and real-time updates. Be careful when disabling the Heartbeat on the frontend, as it might interfere with cart behavior. Always test your checkout flow after making changes.

For Multi-Author Blogs

If you have multiple people editing content simultaneously, do not disable the Heartbeat in the Post Editor. Doing so will stop the "Post Locking" feature, which prevents writers from overwriting each other's work. Instead, simply increase the interval to 60 seconds.

For Resource-Heavy Dashboards

If you use heavy plugins like Elementor or various analytics dashboards, they may rely on the Heartbeat API to keep their interfaces updated. If you notice these tools acting strangely, revert your Heartbeat settings to a more frequent interval.

How XeroWP Helps

At XeroWP, our managed WordPress hosting is designed to handle the overhead of WordPress efficiently. We use high-performance NVMe storage and optimized PHP-FPM configurations that process admin-ajax.php requests faster than traditional shared hosts.

However, even the fastest server has limits. By optimizing the Heartbeat API, you free up those CPU cycles to handle more concurrent visitors and process complex dynamic requests faster. Optimization isn't just about fixing problems; it's about maximizing the ROI of your hosting resources.

Conclusion

The WordPress Heartbeat API is a powerful tool, but it requires a bit of management to ensure it doesn't become a burden. By analyzing your site's needs and adjusting the pulse frequency—or disabling it where it's not needed—you can significantly lower your server's CPU load and provide a snappier experience for both your visitors and your editorial team.

Ready to see how fast your site can be on a platform built for performance? Explore XeroWP’s managed hosting plans today and let us handle the heavy lifting while you focus on growing your business.