Handling 1M+ Records with Laravel Queues & Batch Jobs

How a memory-heavy data process became a reliable background pipeline that could handle more than one million records.

1M+ recordsLaravel queuesBatch jobsS3 exports

The Problem

Processing a large dataset inside one request created memory pressure, timeouts, and poor visibility. If one step failed, the entire workflow often had to be restarted.

The Pipeline

Chunk the source data

Large files were read in manageable pieces instead of loading the complete dataset into memory.

Dispatch batch jobs

Each chunk became a Laravel job for validation, transformation, and persistence, allowing workers to process the workload in parallel.

Track failures and progress

Retries, failed-job handling, batch callbacks, and progress updates made long-running processing visible and recoverable.

Generate results in the background

Exports and final reports were produced asynchronously and stored in S3 without keeping a browser request open.

Result

  • Handled 1M+ records without tying up web requests
  • Kept memory use predictable through chunked processing
  • Allowed failed chunks to retry without restarting everything
  • Made progress and completion visible to users and operators

Key Takeaway

Large data workflows become easier to scale and support when they are split into small, observable, retryable jobs instead of one long-running process.