Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel how to set or define number of workers?

Tags:

php

queue

laravel

In laravel you can start a queue listener with:

php artisan queue:listen

But how many workers (threads, processes) will be used to process the queue?
Is there any way to define the number of workers?

like image 783
giò Avatar asked Sep 17 '25 00:09

giò


2 Answers

https://laravel.com/docs/queues#supervisor-configuration

You generate a config file where you define the number of workers.

numprocs=10
like image 125
cre8 Avatar answered Sep 18 '25 14:09

cre8


By running php artisan queue:listen only one process will be run and fetches the jobs from the queue. So the jobs will be fetched and processed one by one.

If you want to have more than one thread to process the queue jobs you need to run the listener many times in different consoles. But instead of running them manually you can use Supervisor to manage your threads then you will be able to configure the number of thread by setting numprocs parameter in Supervisor configuration setting

like image 25
l3ehnam Avatar answered Sep 18 '25 14:09

l3ehnam