MediaWiki: Find Number of Jobs Pending in Job Queue

Learn how to find the number of pending jobs and how to control job execution rate in MediaWiki.

MediaWiki is a robust content management system written for community use. It provides you with a great number of features that makes an administrator’s life easier. One such feature is job queue. Because MediaWiki has been designed to be simultaneously used and edited by a large number of people –it is imperative to have some sort of job queue in order to execute database update jobs at a time when the system is not too busy. The preference is given to the user request and update jobs are run when system has time and computing power available.

In earlier versions of MediaWiki, Special:Statistics pages used to show the number of jobs in queue that are waiting to be executed. In version 1.19 and later Special:Statistics page does not show pending job count. You can however use MediaWiki API to find out this information. Go to the following page to see the number of pending jobs:

/api.php?action=query&meta=siteinfo&siprop=statistics

This will show you a piece of XML in which “jobs=” property shows the pending job count. For example:

<?xml version="1.0"?>
<api>
  <query>
    <statistics pages="27799397" articles="4013331" edits="547280015" images="789151" users="17204375" activeusers="130014" admins="1463" jobs="27" />
  </query>
</api>

The above example shows that 27 jobs are pending in the job queue.

Please note that use of API should be enabled in LocalSettings.php before you can make use of the above path. The rate of execution of jobs can be controlled by setting $wgJobRunRate variable in LocalSettings.php. By default one job is executed everytime a wiki page is requested by the user. If the server load is too high, you can use $wgJobRunRate to lower the number of jobs per request. For example:

$wgJobRunRate = 0.01;

This will make sure that one job is executed at every ten requests.

Leave a Reply

Your email address will not be published. Required fields are marked *