Laravel Vapor queue sqs doesn't run jobs synchronously

765 views Asked by At

We have an external service which processes a specific task on given data. Because this takes a while per task, and we have ten thousand of tasks we decided to put processing into jobs and a queue otherwise we will get an timeout. Processing all the tasks can be take 15 hours.

So, we decided to split them into chunks and put processing the chunk into a job. So the job will only take about 1 minute.

Considering that the receiving service has limited resources it is important to process each job after each other without a synchronicity.

We put these jobs into a specific named queue to divide this jobs from other jobs like email submitting.

In the local test environment, it works properly with sync, database and sqs.

Now I will explain the issue with the live environment:

When I run the jobs in my local test environment with sqs, invoked by php art queue:listen --queue=name of the queue, all jobs will be written in the "message available" column and one by one will be removed from "message available" column and added to the "message in flight" column. The "message in flight" column has never more than one message.

After deploying everything to production the following happens: The command to add the jobs to the queue will invoked by a scheduler, instead of invoking in console on my local environment. Then all jobs will be added to "message available" column and immediately dozens of jobs will be moved to "messages in flight". That means all jobs from "message available" will be moved to "messages in flight". So that it seems that the jobs won't be processed step by step instead of a kind of brute force.

The other thing is that only 5 jobs will be executed. After that nothing happens, the receiving service gets no requests, the failed_jobs table is empty, and the jobs still remains in "messages in flight".

I have no idea what I do wrong!

Is there another way to process thousands of jobs?

I've set the "queue-concurrency" to 1 and all queues are listed below the "queues" section in vapor.yml. Furthermore, I've set timeout for cli, general and queue to 900 (seconds).

After checking the sqs log file in cloud watch I see that the job has been executed about 4 times.

The time between first job and last job in the log file is about 6 minutes max.

Does anybody has any ideas?

Thank you in advance.

Best Michael

0

There are 0 answers