How supervisor opens queues to run

Tram Ho


Have you ever wondered, how does laravel queue really work, recently had the opportunity to learn so I also want to introduce it to everyone in detail

Group to run queue:work


Is the class that will register the command to run for laravel


1 processing unit, where a processing loop is created, separating the job from the queue for processing (can be understood as a CPU process)

  • In worker create a continuous loop
  • If the queue is paused then stop the job
  • Get the next job from the database job (can be database, redis, …)
  • If there is a job, we will process it
  • After processing the job, sleep for a period of time, then proceed to run the loop again to get the job to run again


Where to create load define job, payload, event, connection setting to store queue


The smallest unit containing the work that needs to be processed, will be pushed to the queue and processed gradually

Queue’s group:listen

Usually used to run commands for local development, like queue:work above but this command helps to listen for source code changes to reload the queue to apply our new code each time we edit.


Where to define command for queue:listen

class Listener

The place to run the process for the command queue:listen, as we can see, is the same as above, it runs in 1 round while (true)

How supervisor opens queues to run

Using a supervisor, we can open an arbitrary number of wokers, suitable for business requirements and server configuration, usually for a mid-range server I think opening 8 => 10 woker is enough

I have briefly described how jobs and workers work in laravel, hope it will help you.

Share the news now