Support » Plugin: WP Statistics » WP Statistics performance issue

  • Hi guys,

    we have used WP Statistics for some time without any issue.But since yesterday we detected that our site have been unstable randomly.

    After some test we found that every time that someone access to WP Statistics overview page, our server is extremely high CPU and memory usage and our site stop responding. We get a lot of “Service Unavailable” messages and none of the widgets show data, only the loading banner and a white background.

    Some minutes after close this page (overview page) the site starts responding again.

    PHP Version 7.2.5
    Wordpress 5.1.1–es_ES
    WP Statistics 12.6.2

    Please, could you help us to solve this issue?

    Thank you very much in advance.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • I have the same problem. Since the most recent update, going to the “overview” page of statistics crashes my site until WP Statistics finally times out and people can get back on the site. None of the stats widgets ever gets loaded – if they contain anything, it’s only error messages.

    Hi @azlivin008

    I noticed that this behavior is only with hosting/ servers with limited resources.

    When you access the “overview” page, the plug-in make (almost at the same time) several requests (POST) to https://www.wellnessdestiny.org/wp-admin/admin-ajax.php to fill all widgets data. Due to some hosting restrictions (CPU, Memory, I/O, max DB Connections, etc), my server is no able to handle all the request at the same time. So, the server begins to reject requests and the clients get “Services unavailable” messages until we closed “overview” page and decreases the server resources usage.

    In order to solve this issue in my site, I have modified the log.js file at wp-content/plugins/wp-statistics/assets/js/ to delay the calls to the function wp_statistics_get_widget_contents one second instead of making all the calls at the same time.

    You can replace log.js code by the following below after every Plug-in update.

    /*
    Function to handle the loading of widget content
    */
    var cr = 1;

    function wp_statistics_get_widget_contents_inc(widget, container_id) {
    //console.log(“widget:”+widget+” container_id:”+ container_id+” “+new Date());
    //console.log(“cr:”+cr);
    var data = {
    ‘action’: ‘wp_statistics_get_widget_contents’,
    ‘widget’: widget,
    };

    container = jQuery(“#” + container_id);

    if (container.is(‘:visible’)) {
    jQuery.ajax({
    url: ajaxurl,
    type: ‘post’,
    data: data,
    datatype: ‘json’,
    })
    .always(function (result) {
    // Take the returned result and add it to the DOM.
    jQuery(“#” + container_id).html(“”).html(result);
    })
    .fail(function (result) {
    // If we failed for some reason, like a timeout, try again.
    //container.html(wp_statistics_loading_image);
    //wp_statistics_get_widget_contents(widget, container_id);
    });

    }
    }

    function wp_statistics_get_widget_contents(widget, container_id) {
    cr = cr + 1;
    setTimeout(function(){ wp_statistics_get_widget_contents_inc(widget, container_id);}, cr*1000);
    }

    function wp_statistics_refresh_widget() {
    var widget = this.id.replace(‘wps_’, ”);
    widget = widget.replace(‘_refresh_button’, ”);
    container_id = widget.replace(‘.’, ‘_’) + ‘_postbox’;

    container = jQuery(“#” + container_id);

    if (container.is(‘:visible’)) {
    container.html(wp_statistics_loading_image);
    cr = 0;
    wp_statistics_get_widget_contents(widget, container_id);
    }

    return false;
    }

    function wp_statistics_refresh_on_toggle_widget() {
    if (this.value.substring(0, 4) != ‘wps_’) {
    return;
    }

    var container_id = this.value.replace(‘wps_’, ”);
    var widget = container_id.replace(‘_postbox’, ”);
    cr = 1;
    wp_statistics_get_widget_contents(widget, container_id);
    }

    function wp_statistics_goto_more() {
    var widget = this.id;

    if (wp_statistics_destinations[widget] !== undefined) {
    window.location.href = wp_statistics_destinations[widget];
    }

    return false;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.