Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mariohbrino's avatar

Queue jobs with multiple threads

I have some jobs that the user requests and it will be executed in the queue with a gap of 1.5 seconds between each job.

I need to execute another job every 15 seconds to fetch some notifications in a RESTFUL API of the jobs that the user requested.

Solution I have so far was to add a fetch notification job between every 15 jobs that the user requested.

I would like to execute the fetch notification job as a background without inject it between the user jobs requested. Also it should not delay the jobs that the user requested.

0 likes
3 replies
mariohbrino's avatar

@andresayej Thanks. I find out a solution based on your answer.

I can send it to different queues and run multiple workers to execute in different process.

1 like
baumgars's avatar

Right, but be careful, jobs are processes not threads. Processes need more heavy loading and memory than threads. And if you have lets say 16 CPU your workers can work only on 16 jobs in parallel. If they manage to run more its because of the operating system doing scheduled switches among the processes to make it look like all are processing the same time.

Please or to participate in this conversation.