From: Bryan Davis Date: Fri, 11 Oct 2013 19:42:10 +0000 (-0600) Subject: Add configurable delay between purgeChangedPages batches X-Git-Tag: 1.31.0-rc.0~18514 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=55651f02f240917b90b90708f13fbf071c8f808a;p=lhc%2Fweb%2Fwiklou.git Add configurable delay between purgeChangedPages batches UDP flooding is possible when purging large numbers of files. This change adds a command line switch to the purgeChangedPages.php maintenance script to insert an artificial delay between purge batches. The intent is to allow the network time to process the batch that was just sent before flooding with a second batch. `--sleep-per-batch` can be used in combination with `--batch-size` to manage network and to some extent query load. A suggested starting point would be to use `--sleep-per-batch=500` in concert with the default batch size of 100 to target a maximum rate of 200 packets/second. Bug: 55632 Change-Id: Ibfc54b1767f145098465404a2b23cd92852e41fd --- diff --git a/maintenance/purgeChangedPages.php b/maintenance/purgeChangedPages.php index e1c6ab6b5a..071ac09c76 100644 --- a/maintenance/purgeChangedPages.php +++ b/maintenance/purgeChangedPages.php @@ -41,6 +41,7 @@ class PurgeChangedPages extends Maintenance { $this->addOption( 'starttime', 'Starting timestamp', true, true ); $this->addOption( 'endtime', 'Ending timestamp', true, true ); $this->addOption( 'htcp-dest', 'HTCP announcement destination (IP:port)', false, true ); + $this->addOption( 'sleep-per-batch', 'Milliseconds to sleep between batches', false, true ); $this->addOption( 'dry-run', 'Do not send purge requests' ); $this->addOption( 'verbose', 'Show more output', false, false, 'v' ); $this->setBatchSize( 100 ); @@ -135,8 +136,13 @@ class PurgeChangedPages extends Maintenance { } // Send batch of purge requests out to squids - $squid = new SquidUpdate( $urls ); + $squid = new SquidUpdate( $urls, count( $urls ) ); $squid->doUpdate(); + + if ( $this->hasOption( 'sleep-per-batch' ) ) { + // sleep-per-batch is milliseconds, usleep wants micro seconds. + usleep( 1000 * (int)$this->getOption( 'sleep-per-batch' ) ); + } } $this->output( "Done!\n" );