Home > Help Center > Applications > WordPress > WordPress Heartbeat

WordPress Heartbeat

The WordPress Heartbeat API communicates with the server at an interval of 15-60 seconds (called tick) providing real-time synchronization between the server and the WordPress dashboard instantaneously.

Below examples might help you understand the heartbeat API better:

  • Creation of periodic auto save and revisions while writing or editing posts.
  • Real-time sales data on the dashboard by ecommerce plugins.
  • Displaying notifications on the WordPress admin dashboard.
  • Showing locking status of a post - when one user is editing a post, all other privileged users will see a message that the post is open (locked) by that specific user.

wordpress heartbeat

WordPress Heartbeat can cause CPU overload

Depending on different scenarios the heartbeat API may send excessive amount of Ajax requests to the server using /wp-admin/admin-ajax.php resulting in high CPU utilization. When this occurs, site performance drops while the CPU load increases.

How do we reduce the server load without losing the useful functionality of WordPress Heartbeat?

Here are some ways you can apply and they will certainly have a positive effect on the site's performance.

Maximize heartbeat intervals

Add the following code to the functions.php file of site's active theme to maximize the Heartbeat intervals:

function wp_heartbeat_settings_3242( $settings ) {
    $settings['interval'] = 120; //Anything between 15-120
    return $settings;
}
add_filter( 'heartbeat_settings', 'wp_heartbeat_settings_3242' );

Reduce the number of revisions.

Log our adminsitration

Do not stay logged in the administration unless you are doing any specific tasks.

Disable dashboard news

Disable all boxes in Screen Options on the Admin Dashboard:

wordpress heartbeat

If the above steps do not result in a significant lowering of CPU load and the main source continues to be /wp-admin/admin-ajax.php add the following code to the beginning of functions.php file to completely stop the WordPress heartbeat functionality:

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

Summary

We hope this article has helped you learn what is WordPress Heartbeat API and how you can limit its negative consequences on site performance.

#wordpress #settings

Still not finding what you're looking for?

Contact our support team with any additional questions or concerns.

Contact support