Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Queue Worker Memory Footprint is Too Big :/

I am running a queue worker that connects to six MQs. When it is brought up, it consumes 25MB of RAM. That is with zero jobs on the queue, i.e. the worker is in a sleep state. I use Larvel for all of my projects, this particular project is purely built for the queue worker (i.e. a microservice with no web access).

I would like to reduce the memory footprint, but more importantly I would like to know where the memory is being consumed. I am using PHP 7.1 so now that xhprof no longer profiles memory I have to figure out an alternative.

I know that Lumen is meant to consume less memory, and it seems at least that Lumen is a subset of Laravel. Is it possible to "turn off" parts of my Laravel app so that it mimics Lumen? I tried commenting out lines from the config/app.php $providers array, but there does not seem to be a big difference in memory consumption (~1MB by my measure).

tl;dr; how to "tweak" the Laravel memory footprint? how to turn Laravel into Lumen?

Thanks

EDIT: Pics or it didn't happen. AFAIK the RES column is in kilobytes, so ~39MB of memory.

RES == 39MB

like image 501
mils Avatar asked Oct 11 '17 23:10

mils


Video Answer


1 Answers

Have you checked your php.ini and turned off any extensions you don't require for your worker & rest of codebase.

You could create a custom php.ini for this worker and supply it via the command line arguments

php -c queue_php.ini artisan queue:work.

Don't forget that the memory footprint you're seeing there is for all of that PHP execution so that includes the JIT Compiler and any extensions loaded and whatever they load.

like image 78
Barkermn01 Avatar answered Sep 18 '22 14:09

Barkermn01