WordPress.org

Ready to get started?Download WordPress

Forums

P2 theme causing very high admin-ajax.php usage (23 posts)

  1. hal9000
    Member
    Posted 4 years ago #

    I have had a warning from my hosts that my site is hammering the cpu (between 60-80%) on a shared host and in the logs it seems to be down to the wp-admin/admin-ajax.hp file.
    This seems to be involved with comment request from the p2 theme (as far as i can tell from the log)
    I know the file is ok as the hashes for the file on my server are exactly the same as from the wp2.84 install file.

    So has anyone got any ideas?
    Does this get used a lot on the P2 theme as when my site gets busy and the server get hammered this won't be acceptable and sustainable by the server hosts. (Xilo)
    I do have a set of about 20 plugins and the theme isn't standard (www.aimb.ws) but this seems to happen even with almost all the plugins disabled.
    Is there anyway of monitoring which files get used lots other than the raw log files.
    Thanks

  2. hal9000
    Member
    Posted 4 years ago #

    It seems that every 15 or so seconds (according to fiddler) the admin-ajax.php checks for new comments and new posts.
    If i had say 20 users sat on the page this would give the server a fair bit of hammering even though the users are not doing anything, right.
    Is this an inherent part of the P2 theme that nothing can be done against

  3. texet
    Member
    Posted 4 years ago #

    go to your functions.php file and delete these two lines:

    add_action( 'wp_ajax_prologue_latest_posts', 'prologue_latest_posts' ); // Load new posts
    add_action( 'wp_ajax_prologue_latest_comments', 'prologue_latest_comments' ); //check for new comments and loads comments into widget

  4. Gene53
    Member
    Posted 4 years ago #

    @texet

    go to your functions.php file and delete these two lines

    Tried it but the only problem is that new post and replies don't appear until the page is refreshed...

  5. hal9000
    Member
    Posted 4 years ago #

    cool that is a plan if the host gets a bit upset.
    Thanks texet that is a good backup
    as gene says this is a dirty fix but not a complete solution as it doesnt function the same.

    althought people are used to pressing f5 to refresh the page which is ok i guess

  6. Gene53
    Member
    Posted 4 years ago #

    Hi Hal, have you checked to see if your server resources have gone down considerably since you applied texet's fix?

    Thanks,
    Gene

  7. Gene53
    Member
    Posted 4 years ago #

    althought people are used to pressing f5 to refresh the page

    Hmm, After applying texet's fix, I wonder if there would be some code that could be added added that would refresh the page after clicking on "Post it"...

  8. hal9000
    Member
    Posted 4 years ago #

    nope not tried it yet - just about to go on hols to south africa for weeks

  9. Gene53
    Member
    Posted 4 years ago #

    @Hal: Have a great vacation!

  10. smallwei
    Member
    Posted 4 years ago #

    Search for "var updateRate" in functions.php.
    You'll see a number. This is the frequency Ajax would check for updates in milliseconds. Update the number to something larger.

    [signature moderated Please read the Forum Rules]

  11. Gene53
    Member
    Posted 4 years ago #

    Thanks smallwei, I'll do that.

    Cheers,
    Gene

  12. Mark Waters
    Member
    Posted 4 years ago #

    I have changed the updateRate from 30000 (30 seconds) to 3600000 (1 hour) but can still see lurking visitors accessing the same page every 30 seconds.

    Is the file cached client side ?

  13. smallwei
    Member
    Posted 4 years ago #

    Mark, how did you find out the accessing time? Did you use firebug? How about when you try it yourself? Is it still hitting it every 30 sec?

    The file shouldn't be cached as far as I know.

    - smallwei

  14. Mark Waters
    Member
    Posted 4 years ago #

    Thanks smallwei , I am using tail to watch the logs via ssh.

    Our apache2 was set to not log our local connections but when disabled I can see all the local machines accessing every 30 seconds just like the outside visitors.

    Here is just one client example :-

    mnhm-5f74c811.pool.mediaways.net - - [19/Nov/2009:08:08:14 +0100]
    mnhm-5f74c811.pool.mediaways.net - - [19/Nov/2009:08:08:44 +0100]
    mnhm-5f74c811.pool.mediaways.net - - [19/Nov/2009:08:09:14 +0100]
    mnhm-5f74c811.pool.mediaways.net - - [19/Nov/2009:08:09:44 +0100]
    mnhm-5f74c811.pool.mediaways.net - - [19/Nov/2009:08:10:15 +0100]

    I am using WordPress-MU if that makes any difference to the way themes are shared / handled.

  15. smallwei
    Member
    Posted 4 years ago #

    Mark,
    It's possible the reason is due to WP-MU.
    Sorry I don't have WP-MU installed so can't really tell you exactly.

    - smallwei

  16. Mark Waters
    Member
    Posted 4 years ago #

    OK , well the constant refreshing doesn't appear to be a problem at the moment as my site isn't busy , but its something to bear in mind.

  17. noel
    Member
    Posted 4 years ago #

    Since the requests are returning 304s and most of the time the request would be cached, this should not be a problem. But please post more information as you come across it.

  18. Mark Waters
    Member
    Posted 4 years ago #

    I have now upgraded to P2 version 1.1.3 and still using WPMU 2.8.6

    Now each client results in these requests every 30 seconds :-

    `88.57.33.153 - - [30/Dec/2009:13:14:57 +0100] "POST / HTTP/1.1" 200 125 "http://micro.blogs.weloveit.info/?p=12960" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; InfoPath.2; OfficeLiveConnector.1.4; .NET CLR 3.0.30729; OfficeLivePatch.1.3)"
    88.57.33.153 - - [30/Dec/2009:13:14:57 +0100] "GET /?p2ajax&action=get_latest_comments&load_time=2009-12-30%2009:14:17&lcwidget=false&vp[]=12960&_=1262175296500 HTTP/1.1" 304 - "http://micro.blogs.weloveit.info/?p=12960" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; InfoPath.2; OfficeLiveConnector.1.4; .NET CLR 3.0.30729; OfficeLivePatch.1.3)"`

    Why is the second request resulting in a 304 ?

  19. Top Cat
    Member
    Posted 4 years ago #

    Hi guys!

    I've been wondering for some time already why the "Add New Post" screen would POST something to the server every minute even when I'm tired of writing and gone asleep.

    First I thought it was a bug with autosaving a draft when no changes to the post are made.

    Now, having discovered the POST's are generated by "Publish" block of the post-new.php page, I'm looking for a way to "fix" it. You know, sometimes it is undesirable to have hundreds of dummy requests spoiling the logs and wasting, say, mobile traffic.

    Any ideas?

    Thanks!

  20. rkord
    Member
    Posted 4 years ago #

    The latest version of P2 theme doesnt seem to have ths code.
    where can I find it?

    tia

  21. tenzece
    Member
    Posted 4 years ago #

    the same problem with the last wordpress

  22. RenFromPenn
    Member
    Posted 4 years ago #

    I don't see any of the code mentioned above anywhere in functions.php. Could you please tell me how to go about implementing this fix in the current version of P2? I need to know ASAP.

  23. gypsie
    Member
    Posted 3 years ago #

    Just update for those who search how to change the frequency of admin-ajax.php calls.

    File is: p2/inc/js.php
    Line 96: var updateRate = "30000";

    If any of you guys from p2 are reading this, I think it would be useful to have this option in Theme Options in admin.

Topic Closed

This topic has been closed to new replies.

About this Topic