aosdev's avatar

Laravel job processing one by one without chains

Hey,

I have a job and putting to queue like 6000 records, the job is requesting to a service, it only works one time at month. Service required 1 second between requests. When i don't use chains, it keeps requesting like 3 times or 4 times at second. So i tried job chains and sleep(1) at my job class. This time when 1 job is failed, stops the entire queue. Also i have two columns "queried_data" and "total_data" columns in my table. So i'm increasing 1 when i query 1 record. So when it makes 3-4 requests per second, my "queried_data" column keeps staying at 25-30 for 100 test records.

Any ideas?

Kind regards.

0 likes
4 replies
krisi_gjika's avatar

So you have a job that spawns 6k more jobs? And each one of these jobs if pinging some external API?

I would suggest delaying the jobs rather than chaining them, change the delay to whatever

$dalay = now();
foreach ($data as $item) {
	Job::dispatch($item)->delay($delay->addSecond());
}
Snapey's avatar

You could put these jobs on their own queue and tell the worker to sleep for 1 second between jobs.

Please or to participate in this conversation.