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

bruno_phrw's avatar

High memory usage with laravel queue

I'm using laravel queue to perform background tasks.

After starting the queue (either with "php artisan queue:work" or with supervisor), htop indicates a memory usage of ~2GB for the process - even with no jobs in the queue.

Here's "sudo systemctl status supervisor" with numprocs = 1 :

supervisor.service - Supervisor process control system for UNIX Loaded: loaded (supervisor.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2023-06-23 11:39:35 CEST; 7s ago Main PID: 2850495 (supervisord) Tasks: 2 (limit: 618982) Memory: 1.9G CPU: 2.574s CGroup: /system.slice/supervisor.service ├─2850495 supervisord -n -c /etc/supervisor/supervisord.conf └─2850496 php artisan queue:work --max-time=10800 --timeout=20 --tries=1

You can see the memory usage at 1.9G (without any job in the queue)

I doesnt seem to increase while processing jobs so I guess I can exclude a memory leak.

Any idea on why the usage is so high ?

0 likes
6 replies
bruno_phrw's avatar

I just tried : php /var/www/html/pharavel/artisan queue:work --max-time=10800 --timeout=7200 --tries=1 --sleep=1

But the memory usage is still 2GB

BTW we just noticed that the exact same config / app only requires 200MB per worker on a different server.

So it seems to be related to a server misconfiguration. Any idea on what could cause that ?

click's avatar

But you mention that if you run php artisan queue:work without supervisor it is also 2GB? So it is not related to supervisor, correct?

you mention it works OK on a different server, do you run the same project on that server?

bruno_phrw's avatar

It's correct. The supervisor itself has a very low memory usage and php artisan queue:work uses the exact same amount of memory for a worker as when started by the supervisor.

You second question is the big mistery here. We run the exact same project on two servers.

click's avatar

So it is not the project, not supervisor. Than it might be a php memory setting somewhere? Are you able to compare your php (cli) ini settings from server 1 and server 2 and see if there are any differences in memory settings?

bruno_phrw's avatar

Good idea ! I dont see any difference but I'll check further

Please or to participate in this conversation.