WordPress Heartbeat and Heavy admin-ajax.php Usage

The WordPress Heartbeat API uses /wp-admin/admin-ajax.php to run AJAX calls from the web-browser. Which in theory sounds awesome, as WordPress can keep track of what's going on in the dashboard.

However this can also start sending excessive requests to admin-ajax.php which can lead to high CPU usage. Anytime a web-browser is left open on a page using the Heartbeat API, this could potentially be an issue.

WordPress Heartbeat API in action

Something handled by the WordPress Heartbeat API is the main WordPress admin dashboard page itself. If all you did was login to WordPress and then minimized that window and started working on something else, you'd see requests for admin-ajax.php in your site's access logs.

At [00:29:30] I logged into the dashboard, and you can see the initial GET /wp-admin/index.php request.

Then at [00:30:31] the WordPress Heartbeat API sends a POST /wp-admin/admin-ajax.php Heartbeat request.

With the WordPress dashboard in focus, a Heartbeat request should be spaced the max of 60 seconds that the API allows for. If the dashboard is out of focus, the Heartbeat requests space out to 120 seconds between them.

Disable WordPress Heartbeat API

If you notice that you are having an excessive amount of admin-ajax.php requests, the WordPress Heartbeat API can be disabled to prevent this type of activity from happening automatically.

Installing the Heartbeat Control plugin

  • First, log into your WordPress admin dashboard.
    Within your dashboard, hover over Plugins and click on Add New.

  • On this page, enter Heartbeat Control into the search box At the top and press the Enter key on your keyboard to perform the search.
    You can find the plugin as Mention in screenshot below





  • As you have searched for the exact name of the plugin, it should be the first result that appears. To install it, click on the Install Now button.

 

  • WordPress will now handle the download and installation of the Heartbeat Control plugin. Of course, be sure to click on Activate Plugin when complete.

 

Configuring the Heartbeat Control plugin

- Now that you have the Heartbeat Control plugin installed, you will need to configure its settings. To access the settings page, hover over Tools on the left side menu bar and click on Heartbeat Control.
- Once on the settings page, you will notice 2 different dropdown boxes. The first box will allow you to disable the WordPress heartbeat on the entire site or on specific locations. Depending on your needs, you may disable the WordPress heartbeat completely, or only allow it on specific locations such as on the post edit page.
- The second box allows you to determine how often the WordPress heartbeat API will make a request. For example, on post edit pages it makes a POST request every 15 seconds. This can be modified within the heartbeat frequency dropdown to delay it up to 60 seconds between requests which would cut down server resources caused by admin-ajax requests by 75%.
- Once your changes are made, click on Save Changes.

  • Email, SSL
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

WordPress wp-cron.php consuming too much memory and cpu

What does wp-cron.php do, anyway? wp-cron.php is a script that carries out the periodic...

[Important] Wordpress Optimization Guide

Hey all,Wordpress is the one of most popular CMS used by All the Web Developers for wasy...