Beanstalkd + supervisor + laravel : Queue processing with more than 10000 jobs an hour
我在Larave 5.2中有一个项目,正在使用:
- 豆茎
- 导师
- Laravel 5.2
- 具有4GB RAM的数字海洋托管
该项目主要基于webhooks。其他网站称为我们的webhook,我将这些webhooks添加到队列中。大约每小时有10000个作业被添加到队列中。
我在超级用户配置中设置了50个num_process。
能否请我建议我如何才能真正快速地处理队列中的作业。这样我就不必等待几个小时来处理我的工作。
这是队列中当前状态的屏幕截图
我们非常感谢您的帮助。
谢谢
主管配置:
1 2 3 4 5 6 7 8 9 10 11 12 | [program:laravel_queue] command=php /var/www/html/nivesh/artisan --env=production --timeout=3600 queue:listen --queue=important,urgent,high,default autostart=true autorestart=true process_name=%(program_name)s_%(process_num)s numprocs=55 stderr_logfile=/var/log/laraqueue.err.log stdout_logfile=/var/log/laraqueue.out.log priority=999 numprocs_start=55 startsecs=0 redirect_stderr=true |
每次加载框架时,Laravel都会极大地影响队列的速度。当您在队列上侦听时,会发生这种情况。
您应该使用--daemon标志运行队列,以避免为每个队列条目重新加载框架:
1 2 3 4 5 6 7 8 9 10 11 12 | [program:laravel_queue] command=php /var/www/html/yopify/artisan --env=production --timeout=3600 queue:work --queue=important,urgent,high,default --daemon autostart=true autorestart=true process_name=%(program_name)s_%(process_num)s numprocs=55 stderr_logfile=/var/log/laraqueue.err.log stdout_logfile=/var/log/laraqueue.out.log priority=999 numprocs_start=55 startsecs=0 redirect_stderr=true |
也有可能将您的Supervisor作业配置文件分解为默认值:
1 2 3 4 5 6 7 8 9 | [program:laravel_queue] command=php /var/www/html/yopify/artisan --env=production --timeout=3600 queue:work --queue=important,urgent,high,default --daemon process_name=%(program_name)s_%(process_num)s numprocs=55 stderr_logfile=/var/log/laraqueue.err.log stdout_logfile=/var/log/laraqueue.out.log numprocs_start=55 startsecs=0 redirect_stderr=true |
我建议您使用
中文件的用户
几个月前,我们确实遇到过类似的问题,这就是我们所做的,
*摆脱日志记录:减少了花费在编写日志上的时间,并加快了队列中作业的执行速度。
*避免外部呼叫:外部呼叫确实需要花费一些时间来获取数据,这也取决于所获取数据的大小。而是尝试在内部存储它们。
*使用子队列:使用子队列执行子任务。
我的建议尝试切换到Redis,因为它易于跟踪作业状态,同时您可以在Redis服务器(redis cli)上编写一些快速查询。
检查是否没有对外部URL的远程调用。
还可以在各个地方添加提示,以了解哪些操作需要很长时间。
尝试将所有队列分解为多个较小的事件,不要将1个冗长的任务分成一系列事件。