WordPress admin ajax – A friend or foe?

Take Control of WordPress Admin Ajax to increase your load time

Recently my hosting service sent me an alert note. I was exceeding their daily CPU usage limit.Guess what was mostly responsible for this? It was non other than WordPress Heartbeat. Is it really beneficial or is it a burden. This post will look at this more closely and show you how to control WordPress admin ajax to solve this issue

Wordpress admin ajax

Know your WordPress Heartbeat & WordPress Admin Ajax

WordPress Heartbeat

A new API was introduced in WordPress 3.6 called WordPress Heartbeat. Aim was to improve communication between your browser and the server allowing a better admin session management.This helps functions such as “Revisions” and “Autosave” to run fast and smooth, when you write a post. Furthermore, if you have more than one admin for a site this will help to make the admin functions easier.

WordPress Admin Ajax

WordPress Heartbeat API uses WordPress admin ajax php to run the script. You will find it in /wp-admin/admin-ajax.php. This script run every few seconds to keep your post editing run smooth. Great isn’t it? Here comes the but…
But this eats up your CPU usage and makes unnecessary calls for this php. If by accident you leave the admin page open and idling, your CPU usage will hit the ceiling. At least thats what happen to me! My hosting team worked on this and identified the culprit as WordPress admin ajax.

You can get some more details about how WordPress admin ajax works on this post.

How did I controlled the situation

Luckily, like most of the things in WordPress, we have options.There are two ways of sorting this out.

Say no and stop it completely

If you really don’t create posts too often, don’t have multiple admins and if your site is a quite static one you can completely disable it via php. I have a news website which completely run on RSS feeds to curate news. I do not write many posts on this and I am the only admin. In there I disabled it completely as shown below.

1. Go to functions.php file in your active theme ( ideally your child theme )
2. Cut and paste this code
add_action( ‘init’, ‘stop_heartbeat’, 1 );
function stop_heartbeat() {

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

Take Control with the plugin

If you run a blog and do frequent posts I think it is best to limit the functions than completely disabling it. In this site I use the plugin called Heartbeat Control to achiev this.

Heartbeat Control

Wordpress admin ajax
It is a superb plugin just to serve this purpose. It’s written by JeffMatson and already had 300,000+ installs.

1. Install the plugin.
2. Go to settings and click on “Heartbeat Control”.
3. Adjust the settings as shown here

Wordpress admin ajax

Both settings come set to “Default”. On the first drop down to select locations, you have options as below.

  • Use Default
  • Disable everywhere
  • Disable on dashboard page
  • Allow only on post edit pages
In the frequency drop down you can select the frequency from 15sec – 60sec at 5 sec intervals.As you can see, I have set it to 60 secs.

That’ how I take control of the situation.That saved me from host shutting down the site! Did you have similar trouble? Any other way you sort this out? Any tricks I have missed? Please let us know.

Leave a Reply

Sorry, is this not what you wanted?

Just tell me what you are looking for !

I will mail them to you, quick as a flash.

Thank you!

Welcome to Easypress it family

Hey ! Glad you are here.

I love sharing these with you all.
Get more free stuff like this even before they are published.
Come join the rest of my buddies.