Run mult jobs in the background

liderbug

New member
Has anyone written the following? I want a web page where I call a function 8 to 12 times. The function takes 1.5 seconds to run. So call the function to the background so all calls run at the same time. Setting in a wait loop until all the jobs are done. Then gather the outputs and display the data.

Thanks
 
PHP don't supports background tasks natively. It is possible, but it's possible.
You can create a queue in the database where you can store all tasks that should be done in separate task. Then create a background-worker.php that will get one task marked as new from queue, mark it as in progress (to not take by another background worker) then it should do what is needed and mark the task as done (or failed) and take another task if exists or wait for new tasks
 
Back
Top