• optimized-marketing

    (@optimized-marketingcom)


    Here is some back story, my webhosting shut all my sites down because admin-ajax.php was creating DB connections and sleep for long periods of time. The highest sleep time I saw was 45s. What I determined is that in one of the WP updates, from WP 3.5 to WP 3.7.1, admin-ajax.php started being called from multiple admin pages (/wp-admin/widgets.php, /wp-admin/index.php, /wp-admin/themes.php, and a few more) ever 2.5-3 min, even if nothing on the pages was touched. While this issue doesn’t cause any problems if you only have one admin page open and close it after each use. But when you have multiple pages open and leave them open all day or over night WP will continue to make the POST to admin-ajax.php. After multiple hours (10+ when it is easiest to see) all of these continual POSTs will starts to negatively impact MYSQL. Database connection from admin-ajax.php will just sleep for multiple seconds even thought nothing is going on.

    For reference In WP 3.5 admin-ajax.php was only called automatically on the post.php page (I believe for autosave purposes). Also on 3.7.1 I switched to the default twenty thirteen theme and deactivated all the plugins and the auto POST things is still occurring.

    What is the point of admin-ajax.php being called on pages where no information was change and no ajax was initiated? Is there a way to turn this off? Is this a feature of WP and expected functionality?

    Thanks
    Greg

Viewing 8 replies - 31 through 38 (of 38 total)
  • [100% WORKING SOLUTION FOR HEARTBEAT API]

    I have written a step by step post on how to solve it i.e. disabling the Heartbeat API eaither completely or fraction of it or if you don’t want to disable it then how to control it.

    Check it out at Solution to Heartbeat API

    You can also message me or comment below the post if you have any query, i’ll be glad to assist.
    [I HAVE TESTED ALL THIS FEATURES AND FOUND IT WORKING]

    Anonymous User 7944234

    (@anonymized-7944234)

    Hi manoranjan_padhy,

    Thanks for that!

    Is it safe to disable heartbeat complete for woocommerce ?

    best regards,
    Ronnie

    Yes you can do this because the theme I am using on my website is already woocommerce and its plugin compatible ! So no worries just go ahead. Moreover you can also comment at the bottom of the post on wordpress site i’ll be glad to assist and even other users will be helped.

    Can i help you any further Robbie ? Thank you! ??

    Anonymous User 7944234

    (@anonymized-7944234)

    Hmmz…

    Parse error: syntax error, unexpected T_FUNCTION in

    Robbie I guess you have done something incorrect because I am actively using it and its working like a charm. I haven’t disabled heartbeat completely, I am using the second solution mentioned in my post! ??

    Manoranjan Padhy, the idea of this community site for the free program WordPress is that you post your solutions HERE and not use this site to get traffic.

    What is worse is that the solutions you post do not work and when people complain on your site you tell them to use option 2, if you know it does not work why waste their time telling them to do it in the first place.

    What you are posting there has been shared in parts here so I hope you do not mind me posting what you put there, back on here:

    Solution for the WordPress Heartbeat API

    Omit the HTML tags you may find in the code e.g
    `

    1.)Completely disable Heartbeat API (DOES NOT WORK)
    1 <br />
    2 add_action( ‘init’, ‘stop_heartbeat’, 1 );<br />
    3 function stop_heartbeat() {<br />
    4 wp_deregister_script(‘heartbeat’);<br />

    2.) Disabling Heartbeat API except the post.php and post-new.php i.e autosave option of WordPress (SUGGESTED)
    1 <br />
    2 add_action( ‘init’, ‘stop_heartbeat’, 1 );<br />
    3 function stop_heartbeat() {<br />
    4 global $pagenow;<br />
    5 if ( $pagenow != ‘post.php’ && $pagenow != ‘post-new.php’ )<br />
    6 wp_deregister_script(‘heartbeat’);<br />
    7 }<br />

    3.) Disabling Heartbeat API on dashboard.
    1 <br />
    2 add_action( ‘init’, ‘stop_heartbeat’, 1 );<br />
    3 function stop_heartbeat() {<br />
    4 global $pagenow;<br />
    5 if ( $pagenow == ‘index.php’ )<br />
    6 wp_deregister_script(‘heartbeat’);<br />
    7 }<br />

    4.) Changing the pulse of Heartbeat API
    1 <br />
    2 function wptuts_heartbeat_settings( $settings ) {<br />
    3 $settings[‘interval’] = 60; //Anything between 15-60<br />
    4 return $settings;<br />
    5 }<br />
    6 add_filter( ‘heartbeat_settings’, ‘wptuts_heartbeat_settings’ );<br />
    `

    I think this Admin-ajax.php is just another example of the completely unprofessional implementation of new features by www.ads-software.com that CRIPPLE thousands of websites.

    Why not implement these as an option?

    In v3.9 we lost features from images and widgets with code stopped working.

    Most professional IT people know about change control, that you allow for training, you do not implement things that mess up people’s sites, instead you make them an OPTION in SETTINGS.

    We should not have to HACK code and now they upgrade point revisions automatically to fix the mistakes, so we mow have our sites going back to wordpress to update code without any authority from the site owner.

    When those updates screw up our sites we look bad

    Again we have tp hack code to disable this madness

    I might have found a solution, in my case the website indeed slowed down and this was caused by the admin-ajax.php.. In case you are using WPML to translate your website, deactivate two options:

    Under the tab Stringtranslations and at the bottom of that page:

    • disable “register strings automaticly for translation”
    • disable “Keep track of were strings appear on the website”

    The two options to disable might have a slight different naming (I’m using a dutch version so I don’t know the exact english title).

Viewing 8 replies - 31 through 38 (of 38 total)
  • The topic ‘Admin-ajax.php being Called from Admin Pages Causing DB Connection Issues’ is closed to new replies.