How to Control the WordPress Heartbeat API for Better Performance

This Q&A explains what the WordPress Heartbeat API does and why its default AJAX calls can overload your server. You’ll see methods for adjusting intervals in wp-config.php, using the heartbeat_settings filter and plugins. Follow this guide to dial in the best timing for your admin screens and front end.

What is the WordPress Heartbeat API, and how can I control it for performance?

The WordPress Heartbeat API makes it possible to exchange data between the browser and server in close to real time. It sends AJAX requests to admin-ajax.php at set intervals. With it, WordPress can autosave drafts, display live notifications and alert when someone else is editing the same post.

Those regular requests can put a strain on server resources, especially if the default timings remain unchanged. Below are approaches you can try to adjust the Heartbeat API and reduce load.

Default Intervals

  • 15 seconds when editing a post or page
  • 60 seconds on the dashboard and other admin screens

Control Methods

  1. Via wp-config.php
    define( 'WP_HEARTBEAT_DISABLE', true );

    This stops all Heartbeat actions; features that rely on it will no longer run.

  2. Using the heartbeat_settings filter
    add_filter( 'heartbeat_settings', 'adjust_heartbeat_interval' );
    function adjust_heartbeat_interval( $settings ) {
        $settings['interval'] = 120; // change to 120 seconds (2 minutes)
        return $settings;
    }

    That snippet sets the interval to two minutes across all admin areas.

  3. Plugins
    • Heartbeat Control by WP Rocket
    • Percona Monitoring and Management (includes Heartbeat settings)

Optimization Tips

  • Increase the interval if real-time updates aren’t needed.
  • Turn off Heartbeat on the front end when it’s not required.
  • Check server performance after changes to find the best settings.

Conditional Front-End Disabling

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