Job queue: Difference between revisions

From USApedia
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Breadcrumbs|align=right|officialwebsite=no|wikipedia=yes}}
{{Breadcrumbs|align=right|officialwebsite=no|wikipedia=yes|mediawiki=yes}}


The '''job queue''' in MediaWiki is a system designed to handle tasks that are too time-consuming or resource-intensive to be performed during a normal web request-response cycle.  
The '''job queue''' in MediaWiki is a system designed to handle tasks that are too time-consuming or resource-intensive to be performed during a normal web request-response cycle.  
Line 5: Line 5:
The job queue allows MediaWiki to defer tasks that do not need immediate execution. This includes operations like updating link tables when templates change, sending notification emails, re-rendering pages after template edits, or any batch processing tasks.
The job queue allows MediaWiki to defer tasks that do not need immediate execution. This includes operations like updating link tables when templates change, sending notification emails, re-rendering pages after template edits, or any batch processing tasks.


== Saintapedia reference ==
== USApedia reference ==


* https://saintapedia.org/w/api.php?action=query&meta=siteinfo&siprop=statistics
* https://openusaproject.com/w/api.php?action=query&meta=siteinfo&siprop=statistics
* [[Special:ApiSandbox]]
* [[Special:ApiSandbox]]


Line 13: Line 13:


=== Cron job ===
=== Cron job ===
<nowiki>#</nowiki>!/bin/bash
<syntaxhighlight lang="bash">
 
#!/bin/bash
<nowiki>#</nowiki> Put the MediaWiki installation path on the line below
# Put the MediaWiki installation path on the line below
 
MW_INSTALL_PATH="/home/www/www.mywikisite.example/mediawiki"
MW_INSTALL_PATH="/home/www/www.mywikisite.example/mediawiki"
RUN_JOBS="$MW_INSTALL_PATH/maintenance/runJobs.php --maxtime=60"
RUN_JOBS="$MW_INSTALL_PATH/maintenance/runJobs.php --maxtime=60"
echo Starting job service...
echo Starting job service...
 
# Wait a minute after the server starts up to give other processes time to get started
<nowiki>#</nowiki> Wait a minute after the server starts up to give other processes time to get started
 
sleep 1
sleep 1
echo Started.
echo Started.
while true; do
while true; do
 
# Job types that need to be run ASAP no matter how many of them are in the queue
<nowiki>#</nowiki> Job types that need to be run ASAP no matter how many of them are in the queue
# Those jobs should be very "cheap" to run
 
php $RUN_JOBS --type="enotifNotify"
<nowiki>#</nowiki> Those jobs should be very "cheap" to run
# Everything else, limit the number of jobs on each batch
 
# The <tvar name=1>--wait</tvar> parameter will pause the execution here until new jobs are added,
php $RUN_JOBS --type="enotifNotify"
# to avoid running the loop without anything to do
 
php $RUN_JOBS --wait --maxjobs=20
<nowiki>#</nowiki> Everything else, limit the number of jobs on each batch
# Wait some seconds to let the CPU do other things, like handling web requests, etc.
 
echo Waiting for 10 seconds...
<nowiki>#</nowiki> The --wait parameter will pause the execution here until new jobs are added,
sleep 10
 
<nowiki>#</nowiki> to avoid running the loop without anything to do
 
php $RUN_JOBS --wait --maxjobs=20
 
<nowiki>#</nowiki> Wait some seconds to let the CPU do other things, like handling web requests, etc
 
echo Waiting for 10 seconds...
 
sleep 10
 
done
done
</syntaxhighlight>


=== Docker ===
=== Docker ===
Line 57: Line 40:


sudo crontab -e
sudo crontab -e
== Errors ==
* PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 20480 bytes) in /var/www/mediawiki/w/includes/parser/Preprocessor_Hash.php on line 704
* PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 20480 bytes) in /var/www/mediawiki/w/includes/parser/Preprocessor_Hash.php on line 709
* PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 1744896 bytes) in /var/www/mediawiki/w/includes/libs/objectcache/MediumSpecificBagOStuff.php on line 1091
* PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 1310720 bytes) in /var/www/mediawiki/w/includes/parser/StripState.php on line 94
* PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 262144 bytes) in /var/www/mediawiki/w/includes/parser/Parser.php on line 3916
* PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 614400 bytes) in /var/www/mediawiki/w/includes/tidy/RemexCompatFormatter.php on line 88


== External ==
== External ==

Latest revision as of 10:45, 2 December 2024

Job queue on Wikipedia
Job queue on Mediawiki

The job queue in MediaWiki is a system designed to handle tasks that are too time-consuming or resource-intensive to be performed during a normal web request-response cycle.

The job queue allows MediaWiki to defer tasks that do not need immediate execution. This includes operations like updating link tables when templates change, sending notification emails, re-rendering pages after template edits, or any batch processing tasks.

USApedia reference

Example

Cron job

#!/bin/bash
# Put the MediaWiki installation path on the line below
MW_INSTALL_PATH="/home/www/www.mywikisite.example/mediawiki"
RUN_JOBS="$MW_INSTALL_PATH/maintenance/runJobs.php --maxtime=60"
echo Starting job service...
# Wait a minute after the server starts up to give other processes time to get started
sleep 1
echo Started.
while true; do
	# Job types that need to be run ASAP no matter how many of them are in the queue
	# Those jobs should be very "cheap" to run
	php $RUN_JOBS --type="enotifNotify"
	# Everything else, limit the number of jobs on each batch
	# The <tvar name=1>--wait</tvar> parameter will pause the execution here until new jobs are added,
	# to avoid running the loop without anything to do
	php $RUN_JOBS --wait --maxjobs=20
	# Wait some seconds to let the CPU do other things, like handling web requests, etc.
	echo  Waiting for 10 seconds...
	sleep 10
done

Docker

* * * * * docker exec web php maintenance/runJobs.php --maxjobs 700 --maxtime=55

sudo crontab -e

Errors

  • PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 20480 bytes) in /var/www/mediawiki/w/includes/parser/Preprocessor_Hash.php on line 704
  • PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 20480 bytes) in /var/www/mediawiki/w/includes/parser/Preprocessor_Hash.php on line 709
  • PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 1744896 bytes) in /var/www/mediawiki/w/includes/libs/objectcache/MediumSpecificBagOStuff.php on line 1091
  • PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 1310720 bytes) in /var/www/mediawiki/w/includes/parser/StripState.php on line 94
  • PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 262144 bytes) in /var/www/mediawiki/w/includes/parser/Parser.php on line 3916
  • PHP Fatal error:  Allowed memory size of 157286400 bytes exhausted (tried to allocate 614400 bytes) in /var/www/mediawiki/w/includes/tidy/RemexCompatFormatter.php on line 88

External