How to Configure WordPress Heartbeat API Frequency to Reduce Server CPU Usage

How to Configure WordPress Heartbeat API Frequency to Reduce Server CPU Usage featured illustration

By

On

The WordPress Heartbeat API is a built-in communication system that lets your browser talk to your server while editing pages. By default, it runs every 15 to 60 seconds, which can spike server CPU usage on budget hosting plans. You can reduce this load by installing a dedicated optimization plugin or adding a small code snippet to increase the time interval between checks.

What is the WordPress Heartbeat API and Why Does It Cause High CPU Usage?

The WordPress Heartbeat API is an internal communication tool that uses regular background script requests (AJAX) to keep your browser session connected to your web server. Think of it like a security guard tapping on your shoulder every minute to ask if you are still awake. While this is helpful for auto-saving drafts, showing post locks when multiple people edit, and displaying real-time plugin notifications, it forces your server to continuously process PHP requests, which consumes valuable CPU resources even when no visitors are actively browsing your site.

What is the WordPress Heartbeat API and Why Does It Cause High CPU Usage?. Three connected stages illustrating the section's sequence for How to Configure WordPress Heartbeat API Frequency to Reduce Serv.
What is the WordPress Heartbeat API and Why Does It Cause High CPU Usage?

For many website owners in Bangladesh using shared hosting packages with limited RAM and processing power, these constant background requests can quickly exhaust server resources. This leads to sluggish admin dashboards, slow page load times, and sometimes even error pages when your hosting provider temporarily blocks your site for using too much CPU.

How Do You Check If the Heartbeat API is Slowing Down Your WordPress Site?

You can identify Heartbeat-related slowdowns by monitoring your browser’s developer tools or checking your server performance logs for frequent requests to the admin-ajax.php file. To check this yourself, open your WordPress dashboard in Google Chrome or Mozilla Firefox, right-click anywhere on the page, and select ‘Inspect’. Go to the ‘Network’ tab and filter the requests by ‘Fetch/XHR’. If you see a repeating request called ‘admin-ajax.php’ firing every 15 to 30 seconds, your Heartbeat API is actively running.

If you notice that your CPU usage spikes whenever you leave the post editor open in a browser tab, the Heartbeat API is likely the culprit. You can also install free monitoring plugins like Query Monitor to see exactly how much server time is spent processing admin-ajax requests.

What Are the Safest Ways to Change the WordPress Heartbeat Frequency?

The safest and most beginner-friendly way to modify the Heartbeat frequency is by using a lightweight optimization plugin like WPCode or Heartbeat Control, which lets you adjust settings without touching server files. If you prefer not to install extra plugins, you can modify your theme’s functions.php file or use a site-specific plugin to add a custom PHP snippet that tells WordPress to check in less frequently or disable the feature in specific areas like the frontend.

What Are the Safest Ways to Change the WordPress Heartbeat Frequency?. Vertical checklist illustration with three marked items for How to Configure WordPress Heartbeat API Frequency to Reduce Serv.
What Are the Safest Ways to Change the WordPress Heartbeat Frequency?

Here is a comparison of the two primary methods to help you choose the right approach for your comfort level:

Method Ease of Use Risk Level Best For
Using a Plugin (e.g., Heartbeat Control) Very Easy Low Beginners and non-coders
Adding Code via WPCode or functions.php Moderate Medium Users comfortable with basic code snippets

Step-by-Step Guide: How to Slow Down the Heartbeat API Using Code

You can safely slow down the Heartbeat API by adding a simple code filter to your site using a code snippet plugin. Follow these steps to adjust the interval from the default 15 seconds to a less demanding 120 seconds (2 minutes):

  1. Log in to your WordPress dashboard.
  2. Install and activate a trusted code management plugin like WPCode (formerly Insert Headers and Footers).
  3. Go to Code Snippets in your sidebar and click Add Snippet.
  4. Select Add Your Custom Code (New Snippet) and give it a clear title like ‘Modify Heartbeat Interval’.
  5. Paste the following PHP code into the code box:
    add_filter( 'wp_heartbeat_settings', function( $settings ) { $settings['interval'] = 120; return $settings; } );
  6. Set the code type to PHP Snippet, toggle the switch from Inactive to Active, and click Save Snippet.

By changing the interval value to 120, your server will only process a Heartbeat request every two minutes instead of every 15 seconds, immediately cutting the associated background CPU load by nearly 85%.

What Potential Problems Should You Watch Out For?

While reducing Heartbeat frequency saves server resources, setting the interval too high or disabling it entirely can affect collaborative editing features. If you set the interval to 300 seconds or turn off the API completely on the post editor screen, you might lose the auto-save feature, or you could accidentally overwrite changes if another administrator is editing the same post at the same time.

What Potential Problems Should You Watch Out For?. Three-step horizontal workflow diagram for How to Configure WordPress Heartbeat API Frequency to Reduce Serv.
What Potential Problems Should You Watch Out For?

Always test your changes after adjusting the settings. Open a draft post, wait a few minutes, and check if auto-saves are still functioning normally. If you manage a single-author blog where nobody else edits your content, you can safely disable the Heartbeat API on the frontend and dashboard entirely without noticing any negative impact.

Leave a Reply

Olivia Masskey

Carter

is a writer covering health, tech, lifestyle, and economic trends. She loves crafting engaging stories that inform and inspire readers.