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.
define( 'WP_HEARTBEAT_DISABLE', true );
This stops all Heartbeat actions; features that rely on it will no longer run.
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.
add_action( 'init', 'disable_heartbeat_on_front_end' );
function disable_heartbeat_on_front_end() {
if ( ! is_admin() ) {
wp_deregister_script( 'heartbeat' );
}
}