4 ms·
What if that request was a document upload and your system is calling out some external api or processing for long enough such that you’d rather return now and
by nsomaru 6y ago
What if that request was a document upload and your system is calling out some external api or processing for long enough such that you’d rather return now and update later when the job finishes. Maybe through Ajax or a redirect.
The shenanigans that WP plugin devs go through to get around the lack of a queue is ridiculous (chunk the file and keep reloading the page until we’ve processed all the chunks or have an Ajax endpoint that processes a chunk at a time...) and the when I asked a marketing friend of mine who works with Wordpress he said that redis is an “advanced requirement” and I should keep things simple.
In Django land I’ve always set up queues even just to send emails because it keeps things snappy.
- simion314 6y agoFor that kind of problem we create a database table. then you schedule there your work tasks and background scripts will fetch jobs from the database and run them. This also works great if the third party is busy or fails, the background jobs are set to attempt a few times before giving up. What solution would you prefer for this kind of jobs? launching a new thread directly? or have a worker project always running and send to it the job directly?
- spdionis 6y agoYou can easily setup and use queues in PHP projects too.
- stephenr 6y ago.... As you identified at the end, the correct solution for this problem is a job queue. There is nothing about PHP that prevents the use of a job queue - in fact the shared-nothing, process-per-request model almost encourages the developer to offload as much work as possible to a job queue.. Using Wordpress (or it's plugins) as any kind of reference for what PHP is capable of, is like using McDonalds as the basis for a cook book.