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

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.

53 thoughts on “Diagnose admin-ajax.php Causing Slow Load Times in WordPress

  1. The abuse of admin-ajax.php can bring down servers… I understand it’s needed on some pages (for carts and other crucial functionality) but I’m seeing a worsening trend of overusing it and making really hard to cache WordPress properly.
    Thanks for this post, I’m sure it will help a lot of people! :)

  2. This article may be exactly what I’m looking for, Brian. My site’s front end is fine, but the admin section is painfully slow recently. Fingers crossed that I can sort it all out…

      • Thanks for responding Terence… I somehow missed your comment Heather. But Terence is correct in the fact that the article above probably won’t fix your backend speed. If your backend is slow it could be a number of issues. Slow host, too many pages (WP recommends under 100, you can have as many posts as you want), etc…

  3. I am facing a problem with my wordpress ecommerce site. When someone try to visit my site it’s blocked by avast. And it’s showing the malicious problem is admin-ajax.php file. I am not able to recognize which code need to remove. Can you please help me? I have tried so many blog but not found exact solution. I want my site will work with avast antivirus without any block.

    Thanks for your time

  4. I recently installed W3 Total Cache to speed up my website and it looked like everything was working. Today when I did a new speed test I noticed that three instances of admin-ajax.php took 1 second to load. Looked at the source code and noticed that calls from Bloom, Monarch and G7 are loaded every reload. Did you find a solution?

    • Make sure you have caching enabled on the Monarch plugin. As far as Bloom goes, I use that too on this blog. Some plugins utilize admin-ajax.php to make calls and so you won’t be able to fix all of them unfortunately.

          • Thanks! I had it on 3 hours, changed it to 4 now. Also installed the Heartbeat Control with your settings. Hostgator is “caching” my website and sending emails that my load is too high. The problem started after I enabled the facebook api thing in the latest version of Monarch. Lets see if this fixed the problem! Thanks for the help.

          • Great Pieter! You might even want to change it up to 6 or more hours. For my clients I have actually started using 12 hours so that it updates twice a day. For my own site I use 3 hours, but I am on a very beefy server. The heartbeat settings can make a world of difference as well. Hopefully that will sort it out for you.

          • The cache setting in Monarch doesn’t matter. Every page where Monarch loads will have six or more POST requests to admin-ajax.php every page load. If you’re using Varnish, this will prevent it from working.

            Heartbeat Control doesn’t affect Monarch either.

            If you reduce the number of social networks, eliminate the visual counters, and don’t use the like/heart button you might get better results, but I haven’t tested it.

          • Strange, as the the cache setting fixed most of my admin-ajax.php POST requests. However I moved away from Monarch as I was consistently not impressed with speed or support.

          • It looks like the requests to admin-ajax are triggered only when you have share totals displayed and then when someone clicks on any of the Monarch buttons. The former condition (and maybe the latter also) prevents Varnish from working, so in hosting environments where Varnish bears the brunt of the load, Monarch is going to slow things down enormously with just a few dozen concurrent visitors.

  5. Hey Brian – thanks so much for this – made a HUGE difference in load speed! :) and so did the monarch settings – awesome!

  6. Awesome! This helped me find the rogue app. I have an Amazon affiliate link generator app that has a “localization” tool (if you want to show different products to different countries). I had thought I turned it off but it turned out I had code in widgets that the plugin didn’t touch and remove. I was able to use GTMetrix to locate the exact issue and now I don’t receive the longer times due to the admin-ajax.php!

  7. Dude, this is a miracle post. I’ve been working for three days on improving my site speed and have tried everything – most suggestions made zero difference or like 1/4 second difference. These two suggestions just carved my load time in half from 4 seconds to 2 seconds. Awesome.

  8. Thanks for this article. I identified AdRotate Pro to be an issue with admin-ajax.php. I changed the group settings of my ads and the load time of 14 seconds was reduced to 3seconds!

  9. Thank you bro… you helping me a lot… I have same problem with you at my social sharing plugin “monarch” that make my site loading almost 15s. I disable it, and my site loading just 2s. So, how to use monarch without loading speed problem??

      • Does SocialWarfare have some kind of generic “like” upvote button to track post popularity?

        Elegant Themes seems to be in a period of strategic disinvestment where they merely maintain existing products without offering anything new or going back and addressing core weaknesses. Their outsourced support system hasn’t changed in years and seems insulated against useful bug reports. I don’t have much use for “support” as such; I’d rather be able to see what their developers are doing and what the known bugs and limitations are.

  10. I have been struggling for ages to try and speed up my wordpress site. From P3 plugin performance through to Super Cache I just haven’t been able to figure it out. I installed a statistics plugin which showed a huge amount of requests to load wp-admin/ajax.php. I searched and found this post, installed Heartbeat control and now my site is super fast!!! Thank you so much.

  11. Hi Brian.

    Thanks very much for this blog post.

    Was wondering what was wrong with my wordpress site.

    Thanks again.

  12. Great Post Man. if we use “”use default” on control heartbeat options the it will remains the same loading time. then whats the usage of heartbeat control.

    it will works fine with “always only on post edit pages”

    Kind Regards
    Rajkumar Kanagaraj

  13. So lets say somebody left up a window at the office which is navigating to a blog post on the admin side. Would that cause unnecessary requests like this? Would it technically be slowing down the site?

  14. Thanks for the article.

    If i understand correctly, those admin-ajax.php calls can disrupt the load time in the frontend only when specific plugins are using it, is that correct?

    if i have a clean wordpress install with no plugins it only affects the CPU of the server while a window with the dashboard is opened and not the frontend load time ?

  15. Hi there. I just wanted to say THANK YOU!
    Editing Pages was super slow and it was just terrible. You saved hours of lifetime and made me very happy.

    -Jan

  16. Hey Brian,

    I installed the heartbeat plugin but when I tried to do the GTmetrix trick it showed nothing, like in your case it shows get share count, in my case it was empty and showed nothing, all blank. What should I do not?

    This is really irritating me.

Leave a Comment

189 Shares
Tweet
Share
Share
Buffer