WordPress; Job Queues and Async Execution

WordPress; Job Queues and Async Execution

queues, async, async tasks

Potrebno mi je često za bilo koji long running tasks.

Postoji nekolicina library-ja od kojih su bar tri od stvarno vrlo renomiranih firmi i nisam prosto siguran koja je najbolja:

  1. By Delicious Brains Inc, je library za non-blocking async requests kao i za background processing po imenom WP Background Processing sa repo na deliciousbrains/wp-background-processing: WordPress background processing class, navodno je inspirisan sa Techcrunch/10up wp-async-task library. Originalni tekst How to do Background Processing in WordPress Plugins and Themes dok primer implementacije možeš pronaći na A5hleyRich/wp-background-processing-example

TechCrunch WP Asynchronous Tasks techcrunch/wp-async-task je za potrebe TechCrunch razvio nižepomenuti tim 10up, a evo i introductionary text Asynchronous WordPress | 10up, a wp-async-task is explained How To Use Asynchronous PHP In WordPress | @thetorquemag ali i also here

WP Queue je takođe library od iste firme, ali mislim da je fokus ka većem broju taskova jer kreira svoje tabele, na repo deliciousbrains/wp-queue i taj library je korišćen za plugin Image Processing Queue sa repo na deliciousbrains/wp-image-processing-queue: Resize WordPress images in the background koji se bavi resajzovanjem slika u pozadini. Pročitaj introducing WP Image Processing Queue - On‑the‑Fly Image Processing Done Right

Još jedan primer i odlično objašnjenje on using the WP Queue to Copy REST API Data to Files

Evo na primer plugin scaffold koji koristi library, SebKay/wordpress-plugin-template: A simple template for creating WordPress plugins.

  1. Automattic preko Woo ima svoj vrlo napredni Action Scheduler - Background Processing Job Queue for WordPress | Action Scheduler - Job Queue for WordPress sa repo na woocommerce/action-scheduler koji uključuje i vrlo lep i savršen Scheduled Actions Administration Screen i to mu je jedna od distinct mogućnosti. Kao i prethodni plugin, koristi svoje custom tabele

Aktelni opis i primena u članu on Creating background processes in WordPress · Florian Brinkmann, a autor takođe misli da je bolji od Delicious Brains rešenja.

This plugin that converts WP Cron into Action Scheduler and displays the admin interface is called Advanced Cron Scheduler for WordPress, although I’m not sure if that’s exactly what I want.

  1. Vrhunska firma 10up, Inc. je napravila 10up/WP-Minions: Job Queue for WordPress, raniji naziv 10up/WP-Gears, ali ovaj lib zahteva Gearman ili RabbitMQ što onemogućava upotrebu za mene, ali je verovatno rešenje za large-scale deployments.

Batch Processing

gdarko/wp-batch-processing: 🚈 Easily process large batches of data in WordPress. Provide the data, setup the processing procedure, run the batch processor from the admin dashboard. Profit.

reaktivstudios/locomotive: Allow developers to easily register batch processes through code, and run them through the admin UI and info at Introducing Locomotive - Reaktiv

Other Async Solutions

humanmade/Cavalcade: A better wp-cron. Horizontally scalable, works perfectly with multisite. je takođe renomirani autor.

Even using AJAX in WordPress je neka vrsta async tasks - iako nije queue, a objašnjenje je ovde How to Use AJAX in WordPress to Load Search Results - WPMU DEV

For task queue, one option is also to use included WP Cron scheduler, WP-Cron je core sistem, that I find clumsy and unreliable, as explained here for One Time Scheduled WordPress Jobs is using wp_schedule_single_event hook.

An old article and custom code on how to execute long running processes in Wordpress - Batch processing for big data - Pippins Plugins

Još jedan library, koji se više ne razvija, je i dfmedia/wp-queue-tasks: Create and process tasks asynchronously in WordPress

Easiest Implementation of WordPress Background Processing - Shahjahan Jewel

Morning-Train/wp-queue: Queue system for WordPress devgeniem/wp-queue: WordPress Queue is a modular library for managing queued tasks in WordPress. withinboredom/wp-queue: An incredibly simple queue system for WordPress

General PHP Task Queues

There are multiple general, non-WordPress specific, PHP task queues libraries and here are some with examples.

PMG Queue — PMG Queue 3.0.0 documentation with repo at AgencyPMG/Queue: A simple PHP task queue. je odličan library koji podržava i in memory driver ali i driver for beanstalkd that uses the pheanstalk library.

Manual custom example code for PHP Queues - Working Smarter, Faster and in Parallel - Juan Treminio - Senior Web Developer Blog that is using pheanstalk/pheanstalk: PHP client for beanstalkd queue as a lib to connect to beanstalkd as a simple and fast work queue.

Tu je i library za Asynchronous and parallel PHP na repo spatie/async: Easily run code asynchronously


Action Scheduler

Action Scheduler u obliku klasičnog i oficijelnog plugina, a potvrđeno poseduje Admin screen. Koristan je i plugin Cleanup Action Scheduler jer skraćuje proceduru čišćenja a pored toga poseduje sve opcije kao i woocommerce/action-scheduler-high-volume ali kroz UI, dok sa druge strane sadrži odvratni Freemius

Which plugins are using Action Scheduler

WooCommerce očigledno, zatim The Events Calendar, WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin, WP Rocket,

Plugin oblakstudio/wp-plugin-installer: Simple plugin installation and activation class ga takođe koristi, što je čudno.

The Imagify is a plugin for WordPress developed by WP-Rocket and it utilizes the Action Scheduler for its operations. The plugin’s repository can be found at wp-media/imagify-plugin.

WP Mail SMTP Plugin takođe ga koristi, a tekst Troubleshooting Action Scheduler Issues - WP Mail SMTP je stvarno koristan i za podešavanja.

Configuring Action Scheduler

Razna podešavanja su opisana ovde WordPress Background Processing at Scale - Action Scheduler Job Queue | Action Scheduler - Job Queue for WordPress, a postoji i oficijelni plugin koji pokazuje kako da podesiš ta podešavanja u kodu, na repo woocommerce/action-scheduler-high-volume: Increase Action Scheduler time limit, queue size and concurrency to process large queues of actions more quickly on high volume websites with more server resources.

Takođe, if you choose to utilize WP CLI exclusively, you can disable the normal WP CLI queue runner by installing the woocommerce/action-scheduler-disable-default-runner: Disable Action Scheduler’s default queue runner, by removing it from the ‘action_scheduler_run_queue’ hook.

Using Action Scheduler

Dobar plugin demo kako da koristiš growdev/action-scheduler-demo: A demo plugin for Action Scheduler.

Action Scheduler version conflicts

Best Practices for Deconflicting Different Versions of Action Scheduler – Woo Developer Blog


Scheduled actions can have statuses failed, canceled or complete, and pending ofcourse.

Removing Scheduled Actions from WooCommerce Action Scheduler - WP Beaches How to clean up WooCommerce Action Scheduler with PHP - WPCodebook Clearing a Clogged Action Scheduler Queue – WooCommerce – Nick Green

date 31. Oct 2020 | modified 10. Jun 2024
filename: Wordpress » Job Queue and Asynchronous