Chat plugin ajax-calls draining server resources -

We started using the chat plugin in bottom-corner (site-wide mode), but discovered that (due to traffic volume) the load imposed on the server by the AJAX hook is too great, so we disabled corner mode. We just put chat on a dedicated http://www.site.com/chat/ static page.

The problem is, our server load is still high (even though its disabled site-wide and only employed on a static page nobody is viewing!)As of this writing we're getting 98 hits/sec on wordpress-chat/wpmudev-chat-ajax.php, with an average load-average of 2.8 (peaking at 5.7 in last 30 hrs) due to the execution of this PHP code. By contrast, our server load is usually about 0.3, maybe 0.6 when we get busy (thanks to W3TC full-page caching).

We had thought that disabling site-wide mode and dumping the page cache would have quit serving code that hits this AJAX hook, and that residual hits were due to client-side cached copies — but looking at the page source there is still mention of the AJAX URL, and the hit-rate is fairly stable (modulo usual diurnal traffic).

How do we employ this plugin without loading the server with unnecessary AJAX requests and how can we squash the traffic we're currently getting?

  • Vaughan

    hiya

    i might need to ask the developer about this.

    if it's just the js that's the issue, maybe we can disable it except for just that page.

    in theme functions.php

    /**
     * Dequeue the jQuery UI script.
     *
     * Hooked to the wp_print_scripts action, with a late priority (100),
     * so that it is after the script was enqueued.
     */
    function chat_dequeue_script() {
    
    if(trim( $_SERVER["REQUEST_URI"] , '/' ) !== 'page-slug') {
    
       wp_dequeue_script( 'wpmudev-chat-js' );
       wp_deregister_script( 'wpmudev-chat-js' );
    }
    }
    add_action( 'wpmudev-chat-js', 'chat_dequeue_script', 100 );

    hopefully the developer might know a better way.

    hope this helps

  • Paul

    @Aleksandar.

    As of this writing we're getting 98 hits/sec on wordpress-chat/wpmudev-chat-ajax.php,

    Yep, that is how. So for chat each user on your site will trigger the chat AJAX update once a second. You can go to Chat > Settings Common and on the first tab 'Poll Interval' you can control how often the AJAX is made. Ant take note there are three different polling definitions but only one polling thread from the browser to the server.

    I would still like to take a look at this if you can provide a real URL I can view the frequentcy of the chat AJAX.

    As for disabling the chat @Vaughan. Thanks for the scripting but this can actually be done within the chat settings. Go to Chat > Settings Common and look for the tab 'Blocked URLs'. There are two sections. On the second section you control where you want front-end exclusions/inclusions. On the drop down 'Load JS/CSS on ALL URLs' select the option 'No, Only URLs where needed for shortcode, widgets, etc.'

  • David King

    @Paul thanks so much :slight_smile:

    - Set to 'No, Only URLs where needed for shortcode, widgets, etc.'

    - So far its looking good :slight_smile:

    - Will update or resolve if it keeps looking fine in the next few hours.

    p.s Suggestion. Perhaps consider making this setting the default when bottom-corner chat isn't enabled?

    p.p.s

    Does this mean it won't work in buddypress mode? I.E does this - 'No, Only URLs where needed for shortcode, widgets, etc.' - prevent the buddypress integration of chat? (We don't have it installed yet, but definetely will be moving to buddypress)

  • David King

    But it is showing the chat shortcode which means you have deactivate our chat plugin.

    Yeah I only temporarily disabled it an hour ago while waiting for support reply. It's now re-enabled without crashing the server. See post above :slight_smile: And specifically this follow up question:

    p.p.s

    Does this mean it won't work in buddypress mode? I.E does this - 'No, Only URLs where needed for shortcode, widgets, etc.' - prevent the buddypress integration of chat? (We don't have it installed yet, but definetely will be moving to buddypress)

  • Paul

    @Aleksandar,

    Does this mean it won't work in buddypress mode?

    No, of course not. The chat code logic is intelligent to know where it needs to run. So when you install BuddyPress and enable chat for a Group it knows it still needs to load the need JS/CSS. Similar with widgets.

    The run on all pages is on purpose because members wanted it so. The reasoning is there are other functions like private chat requests which need to show on all pages. Not to mention being able to control your chat status showing in the WP toolbar. But then again you probably are not seeing/needing those options either.

    Yeah I only temporarily disabled it an hour ago while waiting for support reply. It's now re-enabled without crashing the server.

    Cool. Well from my end I'm seeing the page wrapper but not the chat. Assumed you have this set to not show to public users.

    Let us know if you run into any more issues.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.