Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Prevent Cache Expiration on high Server Load #347

Closed
raamdev opened this issue Oct 4, 2014 · 5 comments
Closed

Feature Request: Prevent Cache Expiration on high Server Load #347

raamdev opened this issue Oct 4, 2014 · 5 comments

Comments

@raamdev
Copy link
Contributor

@raamdev raamdev commented Oct 4, 2014

Requested on WordPress.org:

If the Server Load is greater than a number, DO NOT expire the cached page but serve it from the cache.

Such a feature, utilizing the PHP sys_getloadavg() function, would only work in non-Windows hosting platforms, but nevertheless we could detect if sys_getloadavg() works on the current platform and then provide options for letting a site owner configure a specific server-load at which Quick Cache should not allow cache expiration.


Support threads referencing this issue

@raamdev raamdev changed the title Feature Request: Feature Request: Prevent Cache Expiration on high Server Load Oct 4, 2014
@jaswrks
Copy link

@jaswrks jaswrks commented Oct 9, 2014

Just wanted to comment that implementing this will be super simple once the work in #288 is complete. We can simply connect this to the new purge_ methods in the \quick_cache\share class.

@jaswrks
Copy link

@jaswrks jaswrks commented Mar 15, 2015

This is ready for work IMO.

  • Add a new option in ZenCache Pro that enables this.
  • Add a new option that controls what should be considered too high of a load average; i.e., at what load should purging not occur.
  • Add a conditional check here that stops before purging occurs whenever the load average is high.
  • Also prevent ZenCache from checking the age of existing cache files; i.e., update the AdvancedCache class.
@raamdev raamdev added this to the Next Release milestone Mar 17, 2015
@raamdev raamdev modified the milestones: Next Release, Future Release Apr 10, 2015
@raamdev raamdev modified the milestones: Next Release, Future Release May 16, 2015
@raamdev raamdev modified the milestones: Next Release (Pro), Future Release Jul 10, 2015
@jaswrks
Copy link

@jaswrks jaswrks commented Aug 19, 2015

A new utility was implemented in wpsharks/comet-cache-pro#127

/*
 * System load averages.
 *
 * @since 15xxxx Adding cache directory statistics.
 *
 * @return array System load averages.
 */
$self->sysLoadAverages = function () use ($self) {
    if (!is_null($averages = &$self->cacheKey('sysLoadAverages'))) {
        return $averages; // Already cached these.
    }
    if (!$self->functionIsPossible('sys_getloadavg')) {
        return ($averages = array());
    }
    if (!is_array($averages = sys_getloadavg()) || !$averages) {
        return ($averages = array());
    }
    $averages = array_map('floatval', $averages);
    $averages = array_slice($averages, 0, 3);
    // i.e., 1m, 5m, 15m; see: <http://jas.xyz/1gWyJLt>
    return $averages;
};

Example Usage

$load_averages = $self->sysLoadAverages();
if ($load_averages) {
    // 1 minute ago = (float) $load_averages[0];
    // 5 minutes ago = (float) $load_averages[1];
    // 15 minutes ago = (float) $load_averages[2];
}
@raamdev raamdev modified the milestones: Future Release (Pro), Next Release (Lite) Aug 19, 2015
jaswrks pushed a commit to wpsharks/comet-cache-pro that referenced this issue Aug 21, 2015
raamdev added a commit to wpsharks/comet-cache-pro that referenced this issue Aug 27, 2015
raamdev added a commit to wpsharks/comet-cache-pro that referenced this issue Aug 27, 2015
raamdev added a commit to wpsharks/comet-cache-pro that referenced this issue Aug 27, 2015
raamdev added a commit to wpsharks/comet-cache-pro that referenced this issue Aug 27, 2015
@raamdev
Copy link
Contributor Author

@raamdev raamdev commented Sep 3, 2015

Next Pro Release Changelog:

  • New Feature: It's now possible to "Disable Cache Expiration If Server Load Average is High" (see Dashboard → ZenCache → Plugin Options → Cache Expiration Time). This allows you to provide a specific load average that should cause ZenCache to disable cache expiration and help reduce stress on the server; i.e., to avoid generating a new version of the cache while the server is very busy. Props @jaswsinc. See Issue #347.
@raamdev
Copy link
Contributor Author

@raamdev raamdev commented Oct 2, 2015

ZenCache Pro v151002 has been released and includes changes from this GitHub Issue.

See the v151002 release announcement for further details.


This issue will now be locked to further updates. If you have something to add related to this GitHub Issue, please open a new GitHub Issue and reference this one (#347).

@wpsharks wpsharks locked and limited conversation to collaborators Oct 2, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants