dsifjgogw48491752 2019-06-05 14:52
浏览 89
已采纳

Laravel SQS工作人员挂起

I'm running a worker that processes a sqs-fifo queue and it hangs between jobs (see the times):

[2019-06-05 14:28:10] Processing: App\Jobs\MyApp\MyJob
[2019-06-05 14:28:10] Processed:  App\Jobs\MyApp\MyJob
[2019-06-05 14:28:23] Processing: App\Jobs\MyApp\MyJob
[2019-06-05 14:28:23] Processed:  App\Jobs\MyApp\MyJob
[2019-06-05 14:28:34] Processing: App\Jobs\MyApp\MyJob
[2019-06-05 14:28:34] Processed:  App\Jobs\MyApp\MyJob
[2019-06-05 14:28:34] Processing: App\Jobs\MyApp\MyJob
[2019-06-05 14:28:35] Processed:  App\Jobs\MyApp\MyJob
[2019-06-05 14:28:38] Processing: App\Jobs\MyApp\MyJob
[2019-06-05 14:28:38] Processed:  App\Jobs\MyApp\MyJob

I am using laravel-sqs-fifo-queue driver Any idea what can cause this?

  • 写回答

1条回答 默认 最新

  • douzhuo2722 2019-06-05 16:07
    关注

    From what I know nothing guarantees that after a job has been processed the next job would start inmediately after with no delay. As your queue driver is sqs, your queue listeners need to query Amazon through the internet to get the information needed for the next job to be performed (the next job + the serialized data), you would at least have that network delay from the moment the listener finishes a job and the moment it has the information required for processing the next one. In a multiple listeners scenario that would not be a problem, you can assume a bit of delay among jobs processed by the same listener as other listeners would be concurrently dealing with other queued jobs, but I'm afraid that if you need to sequentially deal with those queued jobs at least that delay is unavoidable.

    Also SQS works with polling, that means that every X slices of time the worker is allowed to ask SQS for the next queued job to handle if available, so you are still fixed to these discrete amounts of time.

    I've also seen on the documentation that a DelaySeconds per queue parameter can be set, as I see your delay seem to be quite bigger than the one mentioned before, I would also check for this parameter on my configuration.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?