🎉 Use coupon MYXERO to enjoy 20% recurring discount on any plan. View Pricing

How to Optimize the WordPress Heartbeat API to Reduce Server CPU Load

XeroWP May 18, 2026 6 min read
How to Optimize the WordPress Heartbeat API to Reduce Server CPU Load

The Silent Resource Drain: Understanding the WordPress Heartbeat API

Imagine you are working on a long-form blog post in your WordPress editor. You leave the tab open while you grab a coffee, and when you return, your hosting provider has sent you an alert: your server CPU usage is spiking. You haven't even published the post yet, and there are no visitors on the site. What happened?

The culprit is often the WordPress Heartbeat API. Introduced in WordPress 3.6, this API provides a way for the browser to communicate with the server in real-time. While it enables essential features like autosaving, session management, and post-locking, it can also become a significant burden on your server resources if left unoptimized. At XeroWP, we prioritize performance, and understanding how to tune this 'heartbeat' is a crucial step in maintaining a fast, responsive site.

How the Heartbeat API Works

The Heartbeat API uses AJAX (Asynchronous JavaScript and XML) to send requests to the server through a file called admin-ajax.php. By default, these requests happen every 15 to 60 seconds. When the browser sends a 'pulse,' the server processes the request and sends back a response.

This communication allows for several key functionalities:

  • Autosave: WordPress automatically saves drafts as you type to prevent data loss.
  • Post Locking: If another user attempts to edit a post you are currently working on, the Heartbeat API tells WordPress to 'lock' that post for them.
  • Real-time Notifications: Plugins use it to display live data, such as sales notifications in WooCommerce or security alerts.
  • Session Management: It monitors if your login session has expired, prompting you to log back in without losing your work.

Why Heartbeat Causes High CPU Load

The problem arises because every single 'pulse' is a full AJAX request. For the server to respond, it must load the WordPress core, the active theme, and all enabled plugins. If you have multiple admin tabs open, or if you have a team of editors working simultaneously, those 15-second requests add up exponentially.

For example, if four editors have three tabs open each, that is 12 concurrent heartbeats hitting admin-ajax.php every minute. On a shared or lower-tier hosting environment, this can quickly saturate the CPU, leading to slow page loads for your visitors or even a '504 Gateway Timeout' error.

How to Diagnose Heartbeat Issues

Before you start disabling features, you need to confirm that the Heartbeat API is indeed the cause of your performance woes.

  1. Chrome DevTools: Open your WordPress dashboard, right-click and select 'Inspect,' then go to the 'Network' tab. Filter by 'XHR.' You will see admin-ajax.php requests appearing at regular intervals. If they are firing every 15 seconds, that is your heartbeat.
  2. Server Logs: Check your access logs for frequent POST requests to /wp-admin/admin-ajax.php. If you see hundreds of these from the same IP address (yours) within a short window, the heartbeat is likely the lead actor in your CPU drama.
  3. GTmetrix or Pingdom: These tools often flag long-running AJAX requests or high server response times caused by background processing.

Method 1: Using the Heartbeat Control Plugin

For most users, the easiest way to manage this is with a plugin. The Heartbeat Control plugin (by WP Rocket) is the gold standard for this task. It allows you to manage the frequency of the API in three distinct areas: the WordPress Dashboard, the Post Editor, and the Frontend.

Once installed, navigate to Settings > Heartbeat Control. We recommend the following settings for a balance of performance and functionality:

  • WordPress Dashboard: Modify Heartbeat to 'Frequency: 60 seconds' or 'Disable.' Most users don't need real-time updates while sitting on the main dashboard.
  • Frontend: 'Disable' completely. Unless you have a specific plugin that requires it (like a live-bid auction site), there is rarely a reason for the heartbeat to run on the public-facing side of your site.
  • Post Editor: 'Modify Heartbeat' to 'Frequency: 60 seconds.' This maintains the autosave feature but reduces the load by 75% compared to the default 15-second interval.

Method 2: Optimizing with Code Snippets

If you prefer to keep your site lean and avoid adding another plugin, you can manage the Heartbeat API using small snippets in your theme's functions.php file or a functional plugin like Code Snippets.

To Completely Disable the Heartbeat API

Use this with caution, as it will disable autosaves and post locking.

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

To Change the Heartbeat Frequency

If you want to keep the functionality but slow down the pulse, use the heartbeat_settings filter. Here we set it to 60 seconds:

add_filter( 'heartbeat_settings', 'xerowp_slow_heartbeat' );
function xerowp_slow_heartbeat( $settings ) {
    $settings['interval'] = 60;
    return $settings;
}

Real-World Scenario: WooCommerce and Heartbeat

WooCommerce sites are particularly susceptible to Heartbeat-related slowdowns. Many WooCommerce plugins use the API to update cart fragments or check for new orders. If you run a high-traffic store, the combination of customer traffic and background AJAX requests can be lethal for performance.

In these cases, we strongly recommend disabling the Heartbeat API on the frontend. If your cart updates aren't working correctly after disabling it, consider using a more modern approach like the 'WooCommerce Cart Fragments' optimization, which handles cart updates more efficiently than the standard Heartbeat pulse.

The Role of Managed Hosting

While optimizing your Heartbeat settings is essential, the underlying infrastructure of your host plays a massive role in how these requests are handled. At XeroWP, our stack is optimized to handle AJAX requests efficiently. We use high-performance NVMe storage and advanced server-side caching that reduces the overhead of PHP processing.

However, even the best server has limits. By optimizing the Heartbeat API at the application level, you free up server resources that can be better spent serving pages to your customers and improving your Core Web Vitals. It is about working in harmony with your hosting environment to achieve the best possible user experience.

Conclusion and Takeaway

The WordPress Heartbeat API is a double-edged sword. It provides the 'magic' that makes the WordPress admin feel modern and reactive, but it can quietly erode your server's performance if left unchecked. By increasing the interval to 60 seconds or disabling it where it isn't needed (like the frontend), you can drastically reduce your CPU load without losing essential features.

Are you tired of dealing with mysterious CPU spikes and slow dashboard performance? Experience the difference of a platform built for speed. Move your site to XeroWP today and let us handle the heavy lifting while you focus on growing your business.