How to Limit WordPress Heartbeat To Lower Executions Numbers Tutorial

Learn How to Set the Frequency of the WordPress Heartbeat

This tutorial covers the following topics:

WordPress 3.6 introduced the WordPress Heartbeat API - it allows your browser to communicate with the server when you're logged into the WordPress admin panel. This functionality allows WordPress to handle things like showing other authors that a post is being edited by another user, plugins can use these script executions and show you notifications in real time, etc.

However, even though this is great functionality it may cause issues in certain cases. On different pages, Heartbeat makes checks on different period - on post edit, it makes it every 15 seconds, on your Dashboard - every minute, etc. Each "tick" generates a POST request which adds to the number of your executions and CPU time used.

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

How to Stop Heartbeat completely

In most cases you can completely disable Heartbeat if you're the only person working at any given time in your site and you know that you don't have any important functionality that heavily relies on it to work properly.

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

This should completely disable this functionality and it will no longer add to the executions number and CPU time used in your account.

How to Limit Heartbeat

If you don't want to stop Heartbeat completely, you can simply limit the execution frequency. You can do this by using a plugin called Heartbeat Control.

You can install it by following the instructions in our tutorial on How to Install WordPress Plugins and activate it. Then go to Settings -> Heartbeat Control Settings and from the Heartbeat Behavior dropdown choose Modify Heartbeat. Then select all Locations and from the Frequency slider choose 60 or above.

By saving the settings you will override the default Heartbeat execution frequency with the value you set on the Frequency slider option.

Alternatively, you can choose the option Disable Heartbeat from the Heartbeat Behavior dropdown and enable all Locations, which should disable the use of the Heartbeat functionality on all of your pages.