简体   繁体   English

Amazon SQS - 并非所有作业都推送到弹性 beantalk 上的队列

[英]Amazon SQS - not all jobs pushed to the queue on elastic beanstalk

Have a laravel project and code block like below有一个 laravel 项目和代码块如下

$pendingToProcessFiles = PendingToProcessFile::where('tries', '<', 3)->orderBy('created_at')->get();

Log::channel('upload-to-s3-jobs-log')->info("Using queue {$this->queue}");

foreach ($pendingToProcessFiles as $index => $pendingToProcessFile) {
    $jobObject = new UploadToS3Job($pendingToProcessFile);
    dispatch($jobObject->onQueue($this->queue));
}

This works as expected in my local machine (laradock), and doesn't matter if I have a lot of records in table, that belongs to PendingToProcessFile model.这在我的本地机器 (laradock) 中按预期工作,如果我在表中有很多记录,属于PendingToProcessFile model 也没关系。

Problem is happening in elastic beanstalk instance, where not all records are processing.问题发生在弹性 beanstalk 实例中,并非所有记录都在处理。 It can process 10 files from 100 records, or 80 files from 1000 records (and not in order that results appear on collection after eloquent query) each time, when cron job is triggering this code block.当 cron 作业触发此代码块时,它每次可以处理 100 条记录中的 10 个文件,或 1000 条记录中的 80 个文件(并且不是按照 eloquent 查询后结果出现在集合中的顺序)。

Tried to add some logging using supervisor configs like尝试使用主管配置添加一些日志记录,例如

[program:upload-to-s3]
process_name=%(program_name)s_%(process_num)02d
command=php artisan queue:work sqs --queue=upload-to-s3 --timeout=600 --sleep=3 --tries=3
directory=/var/app/current
autostart=true
autorestart=true
user=root
numprocs=4
redirect_stderr=true
stdout_logfile=/etc/supervisord.d/output.log
stderr_logfile=/etc/supervisord.d/error.log

But nothing added in those log files (log file is there, I have checked), so I have no idea what's going on here...但是这些日志文件中没有添加任何内容(日志文件在那里,我已经检查过),所以我不知道这里发生了什么......

Btw, upload-to-s3 is standard sqs queue.顺便说一句, upload-to-s3是标准的 sqs 队列。

If someone can give me any advices regarding this, will be appreciated!如果有人可以就此给我任何建议,将不胜感激!

For everyone, who is facing an issues like that, make sure, you are using different sqs instance regions for different environments in aws.对于面临此类问题的每个人,请确保您在 aws 中为不同的环境使用不同的 sqs 实例区域。 For this case issue was, that elastic beanstalk development and production instances were using same sqs instance in same region, and queues let's say were "sharing" between environment and that was making an impression, that job wasn't pushed to queue.对于这个案例,问题是弹性 beantalk 开发和生产实例在同一区域使用相同的 sqs 实例,并且队列可以说是在环境之间“共享”并且给人留下深刻印象,该作业没有被推送到队列中。

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

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