Manual:$wgPoolCounterConf

Details
Configuration for processing pool control, for use in high-traffic wikis.

This configuration array maps pool types to client configurations. A client configuration is an associative array with a class key giving the class name of the client (which should be a subclass of ), and any other elements which are passed through to the class constructor. The constructor receives three arguments: the configuration array, the pool type and a queue name. (The pool type is used to identify the type of work. The queue name determines which requests are trying to do the same work. E.g. the pool type could be article rendering, and the queue name the ID of the revision which is being rendered.)

An implementation using Redis is included with MediaWiki, and another one using a C daemon  is available in PoolCounter.

Pool types
Pool types that can be used as keys for the $wgPoolCounterConf array. More types can be made available by extensions:


 * ArticleView
 * When rendering the contents of a page that it's not in parser cache (including old versions of a page).


 * GetLocalFileCopy
 * When retrieving a file of more than 10MB to local path for thumbnailing.


 * diff
 * When rendering a diff, if the size of the old and new text is greater than 20000 characters.


 * FileRenderExpensive
 * When thumbnailing a file that is considered expensive to thumbnail. The consideration of expensive depends on the file type and image or media dimensions.  Only applies to thumbnails rendered directly from thumb.php.


 * FileRender
 * When thumbnailing a file. Only applies to thumbnails rendered directly from thumb.php.


 * ApiParser
 * When parsing wikitext through the api.


 * SpecialContributions
 * When rendering Special:Contributions.

Configuration options shared by all client

 * timeout
 * Wait timeout in seconds.


 * workers
 * Maximum number of active threads in each pool. Additional workers will wait until a place is freed up.


 * maxqueue
 * Maximum number of total threads in each pool. (If this number of workers are already working/waiting, fail instead of wait)


 * slots
 * Maximum number of workers working on this task type, regardless of queue name. 0 means unlimited. Max allowed value is 65536.  The way the slot limit is enforced is overzealous - this option should be used with caution.

Additional configuration options for the Redis implementation

 * servers
 * List of Redis server addresses.


 * redisConfig
 * Extra configuration array for.

Usage
To use PoolCounter, subclass the  class (or use   which can implement arbitrary functionality with anonymous functions). Three methods/callbacks can be implemented:


 * doWork
 * called when the worker is the first to work on the given task (also when the PoolCounter server is down). Returns the result of the work.


 * getCachedWork
 * called when the worker had to wait on another worker and that worker has finished. Can be used to get a result that has been cached by doWork.  If not implemented or returns false, doWork will be called.


 * fallback
 * called on wait timeout or when there are too many workers waiting already. Can be used to return some not so good but cheap result (e.g. showing a cached older revision instead of rendering the new one).  If not implemented or returns false, error will be called.


 * error
 * Can be used to show an error.

Example
Example configuration:

Example of using PoolCounter:

Example using redis