Table of contents
Book a Maia Demo
Enjoy the freedom to do more with Maia on your side.
Dark green abstract background with subtle gradient shapes and rounded corners.

The workbook was 355 MB. Every run died within 40 minutes.

November 26, 2026
Field Note
4 mins
21 min
355 MB, 14-sheet round trip at 1.4 GB peak
Summarise with AI

A finance team's workbook was 355 MB on disk and 1.8 GB once unzipped, with 14 sheets and 594,491 rows. Every attempt to process it with a script that loaded the whole workbook ran out of memory after 30 to 40 minutes. Streaming it instead brought the full round trip to about 21 minutes, with memory peaking at 1.4 GB, on the team's own runner. It took under 12 hours of engineering across 2 days.

Why the workbook kept running out of memory

An .xlsx file is a ZIP archive of XML, so 355 MB on disk became 1.8 GB of XML to parse. Anything that opens the workbook as an object holds every cell in memory, and this one had 85.2 million cells. One sheet, 445,548 rows by 178 columns, was 93% of the work.

The output had to go back as a single workbook, because that's what the finance team works in. Splitting it into part files wasn't an option.

What Maia does natively, and what we scripted

The Excel Load component loads one data source per component, so 14 sheets means 14 components plus the steps after them, around 28 in all. For one large sheet, its Use Caching option writes to disk instead of memory. Maia has no Excel output component today; unloads write formats such as CSV, JSON, and Parquet.

So we wrote two Python Script components that run on the team's runner. The first streams the workbook out to newline-delimited JSON (NDJSON). The second streams NDJSON back into a 14-sheet workbook.

How the streaming version works

  1. Read row by row. Parse each sheet's XML as a stream and write every row as one NDJSON line. Memory stays flat however many rows there are.
  2. Work on the rows in between. NDJSON is easy to load, inspect, and transform, one record per line.
  3. Write with a streaming writer. Hold a small window of rows in memory, spill the rest to disk, and assemble one sheet per input into a single .xlsx at the end.
  4. Raise the timeout. Python Script defaults to a 300-second timeout. Each step here ran for over 10 minutes.
StepBeforeAfter
Workbook to NDJSONOut of memory after 30–40 min10 min 14 s, 594,491 rows
NDJSON to workbookNot reached11 min 8 s, 268.2 MB file
Peak memoryExhausted1,397 MB

Both steps ran in full in the team's own AWS environment, on Amazon ECS. Python Script runs inside the runner, so a job that peaks at 1.4 GB shares memory with every pipeline on it. Size the runner for it.

The part that bit us: scratch space

The first runs filled the runner's 20 GiB volume with leftover work directories and failed with [Errno 28] No space left on device. The write step alone creates 2.86 GB of temporary XML per run. Three rules came out of it:

  • Size scratch space for the file. Plan for about 2.6 times the workbook's unzipped size, about 4.7 GB here.
  • Clean up on failure too. Delete work directories in a finally block, not only after a successful run.
  • Know your platform's default. Amazon ECS tasks on Fargate get 20 GiB of ephemeral storage unless you set more. On Kubernetes, the runner Helm chart caps the script runner's /tmp at 5 GiB but leaves the main runner's /tmp uncapped, on the node's ephemeral storage.

Where else this applies

It applies to any job where a workbook is the deliverable, such as finance packs, regulatory returns, and planning files. The size is what matters, not the industry. If a workbook is big enough to break an open-the-whole-file approach, stream it.

The format isn't the limit either. In testing, a common Python streaming writer sustained about 153,000 cells a second and a hand-written XML writer about 1.16 million.

Frequently Asked Questions

Why does processing a large Excel workbook run out of memory?

An .xlsx is compressed XML, and this one was about 5 times the size once unzipped. Code that opens the whole workbook holds every cell in memory; streaming reads one row at a time.

Can Maia load several worksheets from one workbook?

Excel Load takes one data source per component, so use one component per sheet, or a streaming Python Script for many sheets.

Can Maia write an Excel file?

Not with a native component today. A Python Script component with a streaming writer can produce a multi-sheet .xlsx.

How much scratch space does a large Excel job need?

Plan for about 2.6 times the workbook's unzipped size, and clean up work directories even when a run fails.

Last updated
November 26, 2026
Ben Bajek
Principal Forward Deployed Engineer, Matillion

Data management
made effortless

Enjoy the freedom to do more with Maia on your side.
Abstract dark teal geometric shapes background with diagonal lines and subtle gradients.