How to Configure the WordPress Heartbeat API to Reduce High CPU Usage and Improve Server Performance

XeroWP Jul 4, 2026 6 min read
How to Configure the WordPress Heartbeat API to Reduce High CPU Usage and Improve Server Performance

Understanding the Pulse of Your Site

WordPress is more than just a static CMS; it is a dynamic application that performs numerous tasks in the background to ensure a seamless experience for both administrators and visitors. One of the most critical, yet often overlooked, components of this background architecture is the Heartbeat API. Introduced in WordPress 3.6, this API allows the browser to communicate with the server in real-time, providing features like autosaving posts, session management, and notifications.

However, this convenience comes at a cost. For many site owners, the Heartbeat API is a silent performance killer. If left unconfigured, it can generate a massive volume of AJAX requests that spike CPU usage, slow down your dashboard, and in extreme cases, lead to server crashes. In this guide, we will explore how the Heartbeat API works, why it impacts performance, and how you can optimize it to keep your XeroWP-hosted site running at peak efficiency.

What is the Heartbeat API?

The Heartbeat API uses a protocol called AJAX (Asynchronous JavaScript and XML) to send requests to the server from the client-side (your browser). Think of it as a constant 'pulse' or 'tick' that happens every few seconds. When you are editing a post, the Heartbeat API sends data to the server to ensure your progress is saved automatically. It also checks if another user is currently editing the same post to prevent 'collision' or data loss.

Key functions of the Heartbeat API include:

  • Autosave: Periodically saving your content drafts.
  • Post Locking: Notifying you if another administrator is editing a post.
  • Login Expiration: Warning you when your session is about to time out.
  • Plugin Notifications: Real-time data updates from e-commerce or analytics plugins.

The Problem: Why Heartbeat Causes High CPU Usage

The issue with the Heartbeat API is its frequency. By default, it sends a request every 15 seconds while you are editing a post and every 60 seconds when you are just sitting on the dashboard. Each of these requests hits the admin-ajax.php file.

On a standard WordPress installation, every call to admin-ajax.php forces the server to load the entire WordPress core, your theme, and all active plugins just to process that single 'tick'. If you have multiple tabs open, or if you have several team members working in the backend simultaneously, these requests multiply exponentially. On shared hosting or smaller VPS environments, this can quickly exhaust available CPU resources, leading to '504 Gateway Timeout' errors or a sluggish frontend for your visitors.

How to Identify Heartbeat Issues

Before you start disabling features, you need to confirm that the Heartbeat API is actually the source of your performance woes. There are two primary ways to do this:

1. Monitor admin-ajax.php in Access Logs

Check your server logs (or the 'Access Logs' section in your XeroWP dashboard). If you see a repetitive pattern of POST requests to /wp-admin/admin-ajax.php coming from the same IP addresses, the Heartbeat API is likely the cause.

2. Use Browser Developer Tools

Open your WordPress dashboard, right-click and select Inspect, then go to the Network tab. Filter by 'XHR'. You will see a request named admin-ajax.php appearing every minute. If you open a post editor, you will see it appearing every 15 seconds.

How to Configure the Heartbeat API

You have three main options for managing the Heartbeat API: using a dedicated plugin, using a general performance plugin, or using custom code.

Option 1: Using the Heartbeat Control Plugin

The most popular and user-friendly method is the Heartbeat Control plugin by WP Rocket. It is lightweight and gives you granular control over where the API runs.

  1. Install and activate the Heartbeat Control plugin.
  2. Navigate to Settings > Heartbeat Control.
  3. You will see three sections: WordPress Dashboard, Frontend, and Post Editor.
  4. For the Frontend, it is usually safe to select 'Disable Heartbeat' unless you use plugins that require real-time updates (like live auctions).
  5. For the WordPress Dashboard, change the frequency to 'Modify Heartbeat' and set it to 60 or 120 seconds.
  6. For the Post Editor, set the frequency to 60 seconds. This ensures you still have autosaves but reduces the server load by 75% compared to the default 15-second interval.

Option 2: Using Performance Plugins (WP Rocket / Perfmatters)

If you are already using premium performance tools like WP Rocket or Perfmatters, you don't need an extra plugin. These tools have built-in Heartbeat management settings.

  • In WP Rocket, go to the 'Heartbeat' tab and check the box to 'Control Heartbeat'. You can then reduce the frequency for different areas of your site.
  • In Perfmatters, go to the 'General' tab and look for the Heartbeat section. You can disable it entirely or increase the interval to 60 seconds.

Option 3: Manual Configuration via Code

If you prefer to keep your site lean and avoid adding another plugin, you can use a PHP snippet in your theme's functions.php file or a site-specific plugin. The following code allows you to change the Heartbeat frequency to 60 seconds:

add_filter( 'heartbeat_settings', 'xerowp_optimize_heartbeat_frequency' );
function xerowp_optimize_heartbeat_frequency( $settings ) {
    $settings['interval'] = 60; // Set the interval to 60 seconds
    return $settings;
}

To disable the Heartbeat API entirely (use with caution), you can use this snippet:

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

Note: Disabling the Heartbeat API completely will break the 'Post Locking' feature and autosaves. We generally recommend modifying the frequency rather than disabling it entirely in the editor.

Real-World Benefits of Heartbeat Optimization

By increasing the Heartbeat interval from 15 seconds to 60 seconds, you are reducing the number of requests by 400%. For a site with five editors working simultaneously, this means the server processes 5 requests per minute instead of 20. This reduction directly translates to lower CPU usage, faster response times for your end-users, and a more stable hosting environment.

At XeroWP, our managed hosting infrastructure is designed to handle high-traffic WordPress sites, but even the most powerful servers benefit from efficient code. By optimizing the Heartbeat API, you ensure that your server resources are spent on delivering content to your customers rather than processing background administrative tasks.

Conclusion

The WordPress Heartbeat API is a powerful tool, but like any background process, it needs to be managed properly. By identifying admin-ajax.php bloat and adjusting the frequency of these requests, you can significantly improve your site's performance and prevent unnecessary CPU spikes.

Ready to experience lightning-fast WordPress hosting without the technical headache? Switch to XeroWP today and let us handle the performance tuning for you. Our platform is optimized out of the box to ensure your WordPress site runs at its absolute best.