简体   繁体   English

Laravel Queue工人记忆足迹太大了:/

[英]Laravel Queue Worker Memory Footprint is Too Big :/

I am running a queue worker that connects to six MQs. 我正在运行一个连接到六个MQ的队列工作器。 When it is brought up, it consumes 25MB of RAM. 当它被启动时,它消耗25MB的RAM。 That is with zero jobs on the queue, ie 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 (ie a microservice with no web access). 我在所有项目中使用Larvel,这个特定的项目纯粹是为队列工作者(即没有Web访问的微服务)构建的。

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. 我正在使用PHP 7.1所以现在xhprof不再是配置文件内存我必须找到一个替代方案。

I know that Lumen is meant to consume less memory, and it seems at least that Lumen is a subset of Laravel. 我知道Lumen意味着消耗更少的内存,至少看起来Lumen是Laravel的一个子集 Is it possible to "turn off" parts of my Laravel app so that it mimics Lumen? 是否可以“关闭”我的Laravel应用程序的部分,以便模仿流明? 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). 我尝试在config / app.php $providers数组中注释掉行,但内存消耗似乎没有太大的差别(我的测量值约为1MB)。

tl;dr; TL;博士; how to "tweak" the Laravel memory footprint? 如何“调整”Laravel内存占用空间? how to turn Laravel into Lumen? 如何将Laravel变成Lumen?

Thanks 谢谢

EDIT: Pics or it didn't happen. 编辑:图片或它没有发生。 AFAIK the RES column is in kilobytes, so ~39MB of memory. RES列的AFAIK以千字节为单位,因此〜39MB的内存。

RES == 39MB

Might this would help to cut down the memory that is used in your queue. 这可能有助于减少队列中使用的内存。

url : Laravel queues - Resource Considerations url: Laravel队列 - 资源注意事项

Resource Considerations 资源考虑因素

Daemon queue workers do not "reboot" the framework before processing each job. 守护程序队列工作程序在处理每个作业之前不会“重新启动”框架。 Therefore, you should free any heavy resources after each job completes. 因此,您应该在每个作业完成后释放任何繁重的资源。 For example, if you are doing image manipulation with the GD library, you should free the memory with imagedestroy when you are done. 例如,如果您使用GD库进行图像处理,则在完成后应使用imagedestroy释放内存。

Have you checked your php.ini and turned off any extensions you don't require for your worker & rest of codebase. 您是否检查了php.ini并关闭了您的工作人员和其余代码库不需要的任何扩展。

You could create a custom php.ini for this worker and supply it via the command line arguments 您可以为此worker创建一个自定义php.ini,并通过命令行参数提供它

php -c queue_php.ini artisan queue:work. php -c queue_php.ini工匠队列:工作。

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. 不要忘记,您在那里看到的内存占用所有PHP执行,因此包括JIT编译器和任何加载的扩展以及它们加载的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM