I am beginner in the Laravel. In my project I need to run a big process divided into smaller chunks.
(i.e) If I have 5000 records to run, I will split 1000 records and to run each 1000 records parallely. I have made the smaller chunks and having a confusion about implementing running records with "Process" and "Jobs" method.
Also In implementing, I will pass the Min id and Max id as parameter to identify which records to run.
Can anyone suggest me which is the best method for this scenario?
Jobs in Laravel are part of its queue system, which is designed for deferred and asynchronous execution of tasks.
VS
Processes in Laravel, typically managed via the Symfony Process component, are suitable for executing command-line scripts or system commands from your Laravel application.
In your case, I suggest you to use Job:
For example:
// Assuming you have a method to calculate chunk ranges
$chunks = calculateChunkRanges(5000, 1000);
foreach ($chunks as $chunk) {
ProcessRecordChunk::dispatch($chunk['minId'], $chunk['maxId']);
}