Diagnose admin-ajax.php Causing Slow Load Times in WordPress

If you have stumbled across this post then you are probably trying to diagnose what is causing your slow load times. And you have probably already narrowed it down to your admin-ajax.php file as the culprit. But why exactly is the admin-ajax.php file causing these heavy load times? Well, read my two suggestions below to try and diagnose the root cause of the problem on your WordPress site. Anyone that knows me or reads my blog knows that I am a little OCD when it comes to speed. I wrote this post for a friend, he knows who he is 🙂

There are two big problems with admin-ajax.php. 1st is WordPress Core and 2nd is Developer’s Plugins

What is the admin-ajax.php file?

Basically in WordPress 3.6 the WordPress Heartbeat API was introduced, which allows WordPress to communicate between the web-browser and the server. This improved upon session management, revision tracking, and auto saving.

WordPress Core using admin-ajax.php

The WordPress Heartbeat API uses /wp-admin/admin-ajax.php to run AJAX calls from the web-browser. While this is great and all it can also cause high CPU usage and crazy amounts of PHP calls. For example if you leave your dashboard open it will keep sending POST requests to this file on a regular interval.

To read more about this issue, I suggest reading this article on WordPress Heartbeat and heavy admin-ajax.php usage.

There is a great free plugin now in the WordPress repository called heartbeat control which can help you fix this problem. Follow the steps below to configure.

Step 1

Install Heartbeat control.

Step 2

Go to Settings and click into “Heartbeat Control.”

settings heartbeat control

Step 3

Under “Control heartbeat locations” you have a couple options:

  • Use default
  • Disable everywhere
  • Disable on dashboard page
  • Allow only on post edit pages (I use the “Allow only on post edit pages” myself)

heartbeat control configuration

You can disable it altogether but remember this controls auto-saving and if you are working on a multi-author blog with multiple sessions this is something to take into consideration. Also the heartbeat API is used by a variety of plugins and disabling it could cause them to stop functioning.

Step 4

Then you can setting the heartbeat polling frequency. I set mine to 60 seconds.

heartbeat frequency

That should hopefully take care of some of your problems. If you are still experiencing delays than I would take a look at the next issue below.

Developer’s Plugins using admin-ajax.php

This is problem I keep running into recently. It seems that a lot of 3rd party developers are now somehow using admin-ajax.php and requests are getting sent for queries within certain plugins. The other day I narrowed down some speed issues on my site and more than a 1 second delay (about 60% of my site’s delay) was being caused entirely by a 3rd party plugin polling admin-ajax.php. Follow the steps below on how you can try and track down which plugin might be causing this. There might be a more efficient way to find this, but so far I have always been able to narrow it down quickly this way without access to the server or installing anything.

Step 1

First go over to GTmetrix and run a free test of your website.

Step 2

Then click into the “Timeline” tab and scroll down. You will most likely have POSTs to admin-ajax.php. In my example below you can see I have 5 POSTS to admin-ajax.php and they are adding up to significant delays.

admin-ajax delays

Step 3

Now expand one of the POST requests and click into the “Post” tab to see additional details. What you care about is the “action” name. From this action name you can usually determine right away what plugin is causing the problem, as the action is usually named something similar to what the plugin is doing or is called. From my example I see it is the “get_shares_count” action. Oh and under “share_count_array” I see it mentions “buffer.” Well there is only one plugin on my site sends requests for share counts from buffer and that is my social media sharing plugin (monarch). So immediately I know what it is. You can then disable your plugin, clear your cache, re-run your test to confirm it. Most likely those admin-ajax.php requests will be gone. For me the fix turned out to be that I needed to enable “caching” on my social sharing plugin in the options.

post details gtmetrix

I have used this method above many times on different sites to quicly narrow down the plugin causing heavy load issues with admin-ajax.php.  You might have to reach out to the developer of your plugin to get a fix.

Additional Ways to Speed up WordPress

If you are looking for additional ways to speed up your WordPress site then I highly recommend you read a couple of my other posts:

The P3 Profiler plugin can also be very useful in determining what plugin might be causing a delay.

As always feel free to leave your comments below!

GET MORE STUFF LIKE THIS

Marketing, WordPress, Blogging Tips, SEO and Reviews, once a week.

Thank you for subscribing.

Something went wrong.

52 Comments

  1. Mark Gavalda January 29, 2015
  2. St. Heather February 10, 2015
    • Terence Milbourn March 25, 2015
      • Brian Jackson March 25, 2015
  3. nando April 24, 2015
  4. imran shahriar June 1, 2015
  5. Adam Roth June 2, 2015
    • Brian Jackson June 2, 2015
  6. Stefan Nilsson July 2, 2015
    • Brian Jackson July 2, 2015
      • Pieter C. July 24, 2015
        • Brian Jackson July 24, 2015
          • Pieter C. July 25, 2015
          • Brian Jackson July 26, 2015
          • Dan Knauss February 18, 2016
          • Brian Jackson February 18, 2016
          • Dan Knauss February 18, 2016
  7. Matt Crystal July 29, 2015
  8. Dollar Flipper August 28, 2015
    • Brian Jackson October 9, 2015
  9. Sourish Nath September 19, 2015
  10. My Five Acres October 9, 2015
  11. Vanessa Harris November 7, 2015
  12. elbsurfer January 11, 2016
  13. Ulwan Irfandi January 18, 2016
    • Brian Jackson January 18, 2016
      • Ulwan Irfandi January 18, 2016
        • Brian Jackson January 18, 2016
  14. Dan Knauss February 18, 2016
    • Brian Jackson February 18, 2016
      • Dan Knauss February 18, 2016
  15. Oliver Cowan March 28, 2016
  16. Simon May 4, 2016
  17. Martin Moerch May 9, 2016
  18. rajkumar June 7, 2016
  19. Tiger June 25, 2016
    • Brian Jackson July 3, 2016
  20. Jimbo August 27, 2016
  21. Brian Jackson August 30, 2016
  22. Brian Jackson September 4, 2016
  23. Roee Yossef January 19, 2017
  24. Jan F. March 1, 2017

Add Comment

159 Shares
Tweet
Share
Share
Buffer