user2189801
user2189801

Reputation: 83

Load time Issues related to admin-ajax.php (with PINGDOM results link)

I am trying to get the load times on my website down. It loads really slowly and iv tried a couple of solutions.

  1. Using gmetrix to solve issues such as optimizing images .
  2. Using pingdom to see what the issues are.

As listed in the below link are the pingdom stats. http://tools.pingdom.com/fpt/#!/cKIvOz/http://healthyeatingandliving.ca/

I have no clue what admin-ajax.php is and why the load on that is so high. Also if anyone knows what the first line is in the file/path column .

If there is anything else i can do to make the load times less since right now its a pain trying to edit content. Thank you to everyone who looks at this.

Upvotes: 3

Views: 24186

Answers (5)

Sourish
Sourish

Reputation: 21

Screenshot of Network-tab in inspector Use the heartbeat control plugin and disable it. Also, in gtmetrix, click on the waterfall chart and then click on post as indicated in the image to figure out whats wrong.

It's a call to the ajax features from a wp plugin called wptouch.

Upvotes: 2

Steve Nisbet
Steve Nisbet

Reputation: 11

I've spent a witless few days trying to sort this same issue out, I've even used the deregister_heartbeat code - to no effect. I wanted to share a solution I put in place to keep Apache / MySQL from dying whilst you try to find out what's going on.

In the end after creating a test copy of the site on a different server and swapping to a default theme I was able to work out that an extention engine in a child theme was making Ajax calls that were somehow getting past the deregistered heart beat - we've now ditched the engine and will probably write the child-theme from scratch.

To buy me some time whilst tracking the offending stuff down I needed a way to drop the threads from the webserver before they occupied all available spaces - and we have a big webserver - it was nonetheless causing sites to crash after only an hour since an Apache restart. You can of course employ a hard Apache restart (apachectl restart or service apache restart on a Debian machine) - but this kills all connections - and in a multi-host environment its going to mess someone up. If you are on an *NIX system, you can do the following, it requires w3m (or equivalent braile-mode browser that can run dumps from the CLI like elinks, lynx or links)

#!/bin/bash
kill `w3m -dump http://<server address>/server-status | grep "admin-ajax.php"|awk '{print $2}'`

Make sure you get the backticks right after the kill and at the end of the script. We basically use w3m to hit the server-status page (you need to have this enabled in your Apache config - make it available only from a local IP address, it gives a lot away) - we pipe the results through grep just hone in on processes that deal with admin-ajax.php - and then we feed those lines into awk which basically returns a list of the associated PID numbers to the kill command.

The result is that the process threads in Apache will die - but will appear for a short while in any server-status list as open slot with no current process - subsequent hits to your site will occupy these threads in a normal fashion again

We put the whole thing into a cron task running every 5 minutes or so - effect is we got the threads appearing, but they never stayed around long enough to cause issue.

Upvotes: 1

Konstantinos
Konstantinos

Reputation: 417

You should add this code to functions.php inside your theme.

add_action( 'init', 'my_deregister_heartbeat', 1 );
function my_deregister_heartbeat() {
    global $pagenow;

    if ( 'post.php' != $pagenow && 'post-new.php' != $pagenow )
        wp_deregister_script('heartbeat');
}

This code will disable the admin-ajax.php feature and reduce CPU by 75%.

Upvotes: 3

Michael
Michael

Reputation: 589

Another plugin or the theme is using something like a cart widget that refreshes when you add to cart etc, this uses admin-ajax and will load on every page, if you deactivate WooCommerce then the problem goes away but the issue is something that depends on WooCommerce.

Upvotes: 1

Robert Lee
Robert Lee

Reputation: 1561

The issue with the ajax load time is with woocommerce scripts running even when you do not have any of the functions needed for your shop on certain pages. I would consider what theses individuals did and have the scripts removed from your regular pages (sorry the website is a little old so you may want to double check and update the enqueue script variables). But to get the gist of it you would basically be removing plugins that are not necessary for the pages that do not require woocommerce functions.

http://wordimpress.com/how-to-load-woocommerce-scripts-and-styles-only-in-shop/

or

http://gregrickaby.com/remove-woocommerce-styles-and-scripts/

You could also add some conditional tags so that it specifically does not load on certain pages.

https://codex.wordpress.org/Conditional_Tags

Upvotes: 1

Related Questions