• 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 15 replies - 16 through 30 (of 38 total)
  • 1) OK – I took the code mentioned above —

    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’);
    }

    2) pasted it into my functions file

    3) ran a speed test at pingdom https://tools.pingdom.com/fpt/#!/ejOa0r/https://www.halfpipelondon.com/product-category/bike/bicycles/womens-bicycles/

    4) still getting this ajax problem

    5) anyone got more ideas

    Ian

    It’s a pity that the default behavior for this functionality is not OFF.

    We have a dedicated server with > 200 members and one member left his browser sitting on the profile page for 3 days. The end result was after the weekly log rotation process Apache could not write to the new log files. Took me a couple of days to figure out what was going on.

    Only resolved the issue by restarting Apache.

    I’ve since implemented the following in the themes function.php (similar to above, but works)

    function my_deregister_heartbeat() {
    	global $pagenow;
    
    	if ( 'post.php' != $pagenow && 'post-new.php' != $pagenow ) {
    		wp_deregister_script('heartbeat');
    		wp_register_script('heartbeat', false);
    	}
    }
    add_action( 'admin_enqueue_scripts', 'my_deregister_heartbeat' );

    Sorry guys, but in it’s current form this feature is a serious brain-fart!

    It works!! Great

    One site down by the script. (Internal Server Error) Is not a great solution in the end.

    the code did not work for me – are there any other fixes out there?

    i disabled the new order email notification and this SIGNIFICANTLY improved the load time. The load time is still not ideal but this is the only thing that has seemed to work. Please note, I did not disable customer email notifications, just the email that gets sent to me when a user submits an order. Easy fix and very helpful.

    Please note I tried all of the following, but the only thing that helped was email deactivation.

    My server is digitalocean 2GB Ram 30GB SSD Disk.

    I have tried:

    1) deregistering the heartbeat api
    2) increasing the memory limit (96M) and php memory limit (64M)
    3) my WP URL and site URL match
    4) switched to default wp theme (no change)
    5) same issue on http and https
    6) logged in and non logged in – issue persists

    disabling the email seemed to be the thing that fixed this issue

    I have the same problem!

    The code is not working for me. Deactivating the email function cannot be the solution, have not tried it yet but I want to keep this function alive.

    The load time of the admin-ajax.php takes somewhere between 1 and 1,6 seconds!

    Have also a VPS 2gb ram and wordpress gets 128mb of it.

    Would be nice to get help on this issue.

    Where do you add this into the Theme’s functions./php file, at the beginning, end or before the first function definition?

    Our backend is incredibly slow and this is the first real option I have seen that has the potential to make a big difference.

    No good recommendation for this problem so far.

    Mi página ver películas en linea también tiene el mismo problema… active el código en function.php pero igualmente continua lento. Y ya me bloquearon de mi hosting

    Anonymous User 7944234

    (@anonymized-7944234)

    I Just can NOT understand there is NO solution for this BIG problem.

    https://www.ads-software.com/support/topic/admin-ajaxphp-very-long-loading-time-woocommerce?replies=8″

    https://www.ads-software.com/support/topic/admin-ajaxphp-slow-server-response-time?replies=28″

    This solution in my theme functions also does not work:

    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’);
    }

    PLEASE HELP !!

    Also been having this issue. Have searched all over the place with the only answer being to disable the heartbeat. Ive done that and no change was made. Pingdom still showing adam-ajax taking up to 30 seconds at times (generally takes about 6-10seconds). It must be a plugin but ive tried disabling them and still having the issue. Going nuts.

    It wouldnt let me edit my post so having to post again…

    I seemed to have fixed the problem and narrowed it down to one of two plugins I had.

    So I updated to workpress 3.9 today and my site didnt like it. LayerSlider bugged out and would no longer show, and my tmeplate hasnt updated yet.

    I also noticed there was an update for Better Security, so I updated that. My site definitely didnt like that update as the whole site bugged out. Couldnt even reach my dashboard.

    So I went into my FTP and removed Better Security and LayerSlider since I couldnt use it at the moment.. then after that, admin-ajax doesnt even show up on pingdom anymore.

    Soooo.. I guess the problem is fixed?

    andddd its back. Absolutely no idea what is causing it after-all. 9second loading time for admin0ajax. fun stuff

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