Processing 1M+ Excel Rows with Laravel Queues

I rebuilt a memory-heavy Excel import as a background pipeline that processes large datasets without blocking the website or requiring users to keep their browser open.

1M+ Excel rowsLaravel queuesBatch jobsS3 reportsWebSockets

The Challenge

Processing an entire workbook inside a web request caused high memory usage, timeouts, and poor visibility. A failure could stop the full process, and restarting it repeated work that had already succeeded.

The Solution

Queue-driven processing

The upload request starts the workflow, while Laravel workers handle validation, transformation, database processing, and report generation in the background.

Chunked jobs and coordinated stages

Files are split into bounded chunks and grouped into chains and batches so dependent stages run in order while individual units remain retryable.

Efficient Excel previews

XML streaming reads only the header and sample rows needed for a preview instead of parsing an entire million-row workbook.

Visible progress and isolated failures

Upload states and WebSocket updates show progress, while failed stages are recorded separately and validation reports are stored in S3.

Technical Challenge

The workflow contained dependent stages: validation had to finish before processing, and post-processing had to wait until the main records were ready. I combined Laravel job chains and batches to preserve that order while keeping work inside each stage small and recoverable.

Production Safeguards

  • Explicit waiting, processing, completed, and failed upload states
  • Independent retries for failed chunks instead of full restarts
  • Stage-specific errors that prevent uploads from appearing stuck
  • Downloadable validation reports stored securely in Amazon S3

Result

  • Supported Excel files containing more than one million rows
  • Kept heavy processing outside normal web requests
  • Controlled memory use through bounded, chunked processing
  • Kept the application responsive while users tracked progress
  • Made failures recoverable and validation errors downloadable

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.

Technologies

PHP, Laravel, Laravel Queues, Laravel Batch Jobs, Redis, Amazon S3, Laravel Vapor, Excel and XML streaming, React, TypeScript, and WebSockets.