How to Limit WordPress Heartbeat To Lower Number of Executions Print

  • Wordpress Heartbeat, Limit Number of Executions on Wordpress, Disable Wordpress Heartbeat
  • 786

Learning.png

The WordPress Heartbeat API allows your browser to talk to your server and manage things like showing other authors that a post is being edited by another author.

WordPress plugins also use these script executions and show you real-time notifications.

As much as this functionality is helpful it can cause performance-related problems too.

For instance, on WordPress pages Heartbeat makes checks on different periods; on post edits, it makes checks every 15 seconds; and on your WordPress Dashboard – every minute.

Each Heartbeat check generates a POST request which in turn adds to the number of executions and CPU time used.

This functionality uses the wp-admin/admin-ajax.php file to make AJAX calls. If you notice performance degradation due to a significant amount of POST requests by that file, you need to limit the work of Heartbeat or stop it completely.

How to Stop Heartbeat

You can completely disable Heartbeat if you’re the only person working on your WordPress site at any given time, as long as you don’t have any important functionality/plugin that relies on it to function properly.

To disable it, edit the functions.php file of your theme and paste these lines right after the opening <?php tag:

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

This should disable this functionality and ensure it won't add to the execution number and CPU time utilized in your Rocket Domains Google Cloud environment.

 


Was this answer helpful?

« Back