Engineering · Ingestion

How we ingest thousands of documents in minutes Measured: 1,000 PDFs, 18,000 pages, searchable 3.4 minutes after the first byte is sent. The trick: stop reading a document from start to finish, and stop waiting for the upload to end.

In 30 seconds
  • Reading a document is six steps. Done one document at a time, the biggest file in the zip sets the pace while the other workers watch.
  • So we took documents apart: every step of every document is a separate job, and any free worker takes the next one. An orchestrator puts each document back together.
  • That orchestrator first ran out of memory. Now it holds pointers: links to files in storage, not blobs of data. Its memory is the same for 1 document as for 1,000.
  • One line, not lanes: on Kafka half the workers sat idle while jobs waited in other lanes. A shared RabbitMQ queue, where the next free worker takes the next job, took the same ten PDFs from 64 to 40 seconds.
  • Read as it lands. The browser opens the zip itself and sends the documents in bundles of a few megabytes; each bundle is read the moment it arrives, so the reading runs alongside the upload instead of after it.
  • Book the servers at the door. An upload announces its size when it starts; burst servers boot while the files arrive, Ray puts each job on a free CPU across them, and they are deleted when the queue empties.
  • Embedding is not CPU work. It waits on a hosted model, so it has workers of its own, and two hosts serving the same model share it.
  • Big files are cut by size. A 934 MB CSV, a 476 MB text with no headings, a Word file of 30 large photos: each is cut into blocks a small worker can hold, pictures are jobs of their own, and a job that outgrows its worker runs again with more memory.
  • A whole public benchmark: FinanceBench's 368 company reports, 54,120 pages, all searchable 12.1 minutes after the first byte.
  • A restart resumes, it does not start over. Each document is a durable workflow (DBOS, on the Postgres we already run): every answer from the workers is a checkpoint. Killed halfway through a 400-page PDF, the orchestrator came back and sent only the 24 parts not yet done, none of the 16 already done.
3.4 min
1,000 PDFs, 18,000 pages, first byte to all searchable, none failed
~60 s
from the upload's first byte to burst servers taking jobs
~500 MB
whole web-server memory, flat from 1 to 1,000
12.1 min
FinanceBench, whole: 368 reports, 54,120 pages, none failed
110 s
until its first report is searchable
521,653
passages embedded and stored

Measured on our servers, 18 November 2026, sent from a server in the same region: 4 small servers always on (2 shared vCPUs each), plus 10 burst servers of 16 shared vCPUs, booked when the upload started.

The problem

A zip lands. Make it searchable before the coffee is ready.

VectoGrid answers questions about your documents and points to the page each answer comes from. It cannot do that by reading every file each time a question comes in. Each document is read once, in advance, and turned into something searchable: its text is cut into short passages, and each passage gets an embedding, a list of numbers that captures what it means, so a question can find the right passage by meaning and not only by matching words. The passages and their embeddings go into a vector database. This reading-in is called ingestion; in RAG (retrieval-augmented generation) terms, the documents are embedded. Questions can only be asked once it is done, which is why its speed matters.

So someone drops a zip of ten PDFs on VectoGrid. Before a single question can be answered, each document goes through six steps:

StepWhat it doesTypical time
1. SplitCut the PDF into standalone parts of 10 pages, so several workers can read one document at once.0.6 s
2. Convert to textTurn each part into text: words in reading order, headings, tables, and each page's number. Scanned pages go through OCR. The slow step.4.8 s
3. JoinPut the parts' text back together, in page order, into the whole document, so the next step sees it whole.0.5 s
4. Cut into passagesCut the document's text into short passages, each knowing its page.2.7 s
5. EmbedGive each passage its embedding, by calling an embedding model.4.0 s
6. StoreWrite the passages and their embeddings to the vector database.1.1 s

Times are for a typical 18-page PDF: the median of 1,000 such PDFs in our largest run. A longer document takes longer, mostly in step 2. Other formats are split their own way: a spreadsheet or CSV in blocks of rows, a Word, HTML or text file in sections, a mailbox into its mails, a zip into its files, so a big file of any kind is spread over many workers; from step 3 on, every file type is the same text.

Why join before cutting into passages? The 10-page parts are a cut for speed, not for meaning: a paragraph or a table can run from page 10 onto page 11, across two parts. Cutting each part on its own would break it in two, and a passage on page 15 would lose the heading it sits under on page 12. Joined, the document is cut where its meaning breaks, and every passage still knows its page.

About 15 seconds for one document. The obvious plan for ten is to give each one to a worker and let it run the six steps from start to finish. It is also the plan that falls over first.

Why the obvious plan stalls

The elephant in the zip.

Zips are never fair. Nine memos and one 300-page annual report: nine workers finish in seconds, then stand around while the tenth reads all 300 pages alone. The zip is done when its slowest document is done, and that one used a single worker.

It goes wrong the other way too. Ten documents on a hundred workers leaves ninety idle, however long the documents are. Whatever number of documents you read at once, it is wrong for some zip.

One worker per document versus every step a job A 60-page report, a 20-page memo B and a 3-page memo C on three workers. Top: each worker runs every step of one document, the report's six parts one after another on worker 1; the memo workers finish early and sit idle while worker 1 reads the report alone. Bottom: the report and memo B are split into 10-page parts; memo B's two parts run on two workers and it is joined, chunked, embedded and stored early, because finishing jobs jump the queue; memo C is read whole and finished early too; the report's six parts fill the gaps on all three workers; then the report's join, chunking, embedding (three batches on three workers) and store follow, each waiting for the one before. Almost no worker is idle, and everything is searchable well before the top plan. report, 60 pages memo B, 20 pages memo C, 3 pages One worker per document W1W2W3 splitpp. 1–10pp. 11–20pp. 21–30pp. 31–40pp. 41–50pp. 51–60joinchunkembedembedembedstore split pp. 1–10 pp. 11–20 join chunk embed store idle read chunk embed store idle time →all searchable Every step a job on one shared queue; any free worker takes the next W1W2W3 split pp. 11–20 pp. 1–10 pp. 21–30 pp. 41–50 split pp. 1–10 join chunk embed store pp. 51–60 read chunk embed store pp. 11–20 pp. 31–40 join chunk embed embed embed store all parts back joined chunked embedded time →all searchablefinish above Illustration, not to scale

Top: two workers finish their memos and sit idle while W1 works through the 60-page report. Bottom: the report becomes six 10-page convert-to-text jobs; as workers finish other jobs, they pick up its parts from the shared queue. The dashed lines are the report's own order: joined once all six parts are back, then chunked, embedded and stored. The whole upload is searchable sooner. The white space is that last wait; in a real zip, other documents' jobs fill it, and only the very last document leaves a little idle time.

The idea

Take the document apart.

A restaurant kitchen does not give each table its own cook who makes the starter, the main and the dessert. Orders become tickets, every cook takes the next ticket, and the pass puts each table's plates back together before they go out.

We did the same with documents. Every step of every document becomes a small job on one queue. A 40-page PDF becomes one split job, then four convert-to-text jobs, one per 10-page part, that run side by side on four different workers. Memo B's chunking and the annual report's page 210 can sit next to each other in the queue; no worker cares whose job it is.

The orchestrator is the pass. It keeps one small record per document: which parts went out, which came back. When the last part of a document returns, it queues that document's join; when the join is done, its chunking; and so on to the vector database. Documents stay whole for the user; only the work is in pieces.

Two details make it fair:

  • Ten pages is the unit. A 300-page report is 30 jobs, spread over every worker there is, so the elephant no longer sets the pace.
  • Finishing jobs go first. A join or a chunking job jumps the queue, so the first documents are searchable while the rest of the zip is still being read, not all at the very end.
The memory bill

Pass the address, not the house.

Our first orchestrator was a very hands-on pass. It received each document's pages, joined them itself, sent the text out to be chunked, got the chunks back, sent them out to be embedded, got the vectors back and wrote them. Every document in flight sat in its memory. At 100 documents it passed 2 GB and the server stopped answering.

The fix is a pointer. Every file, part, page, chunk list and vector set lives in object storage, on a server next to the workers. A job carries signed links: read this, write your result there. An answer is a few lines: done, it is there. The orchestrator holds about a kilobyte per document, links and timings, never the content.

Orchestrator holds100 documents in flight
the documents' text, chunks and vectorsover 2 GB, then the server stopped answering
links onlyabout 500 MB; the same at 1,000

The 500 MB is the whole web server, the website and the API around the orchestrator, and it did not move during the 1,000-document run. A 2,000-page PDF full of photographs is just a bigger object in storage: the message about it is the same few hundred bytes. With nothing big in memory, there is no limit to tune, and nothing that jumps when the zip gets bigger.

The idle-worker bug

One line, next free till.

Our first queue was Kafka, and it behaved like a supermarket with assigned lanes: each job was sent to a lane in advance, and each lane had its own worker. A long job held up its lane while the worker next door had nothing to do. About half the workers sat idle. Kafka has an answer on the way, share groups ("queues for Kafka", KIP-932), where any free worker takes the next message; it is still a preview feature, not something to build production on yet.

A bank queue does it better: one line, next free till. That is a RabbitMQ queue with one setting, prefetch 1: a worker holds one job at a time and gets the next only after it answers. Without it, RabbitMQ would push several jobs to a busy worker in advance, and they would wait behind its current one.

Same servers, same ten documents: 64 seconds on Kafka, 40 on RabbitMQ.

Embedding is the one exception. An embedding job is a call to a hosted embedding model, one per 256 passages: the worker mostly waits on the network, not on its CPU. Put on the same line as the CPU jobs, a worker waiting on the model is a till with nobody serving, and the CPU jobs queue behind it. So embedding jobs have their own line and their own workers, dozens per server, which cost no CPU. Their pace is set by the model's host, so two hosts serve the same model (the same vectors, to five decimals): each worker prefers one, and goes to the other when the first is busy or down.

The upload

Do not wait for the zip.

The obvious way to send a library is one zip: upload it, unpack it, then read it. Every document waits for the last byte of the whole zip, and the servers wait with them. On an office line, a few hundred megabytes is minutes of nothing.

So the browser opens the zip itself. A zip keeps its table of contents at its end; the page reads that, then cuts each document out of the file when it is its turn, so a zip of any size is never read whole. Small documents travel in bundles of about 6 MB: every send costs a round trip whatever its size, and a thousand one-page sends would spend more time asking than sending. Each bundle goes straight to storage, an S3 bucket next to the workers, never through the web server: the API hands the browser a presigned URL for each bundle, a link that lets it write that one object and nothing else, for a short while. The browser says when a bundle has landed, and its documents are on the queue that moment. The reading runs alongside the upload, and the last bundle finds the fleet already working.

The servers are booked at the door. When an upload starts, it tells the fleet how many documents are coming, and the controller asks for burst servers there and then, all at once, while the files are still arriving. They boot from a ready-made image, join the cluster about a minute later, and are deleted when the queue empties. The burst servers form a Ray cluster, which places each job on a free CPU and gives a file too big for a small worker the memory it needs (the story: One job waiting, four servers idle, and none can run it).

1,000 PDFs, 305 MB, same fleetSentAll searchable
Upload the zip, then unpack and read it10 s4.8 min
Bundles read as they land, servers booked at the start7 s3.4 min

Both sent from a server next to ours, so the upload itself is quick and the difference is the waiting. Times from the first byte sent. From a home line (305 MB in about two minutes), the last document was searchable 80 seconds after the last bundle landed.

A real library: FinanceBench in 12 minutes

Slices of 18 pages are a fair test of the machinery, not of real documents. So we sent a whole public benchmark the same way: FinanceBench, the 368 annual and quarterly reports of US companies its questions are asked about. That is 54,120 pages, most reports past 100 pages and one past 580, 674 MB in all.

FinanceBench, 368 reports, 54,120 pagesFrom the first byte
Sent (106 bundles)11 s
First report searchable110 s
Half searchable7.4 min
All 368 searchable, 521,653 passages, none failed12.1 min

Real files bring real damage: one report had a broken internal index past page 150 and could not be cut into parts. It is now rewritten once and read like the others. The run also showed where the next minute is: the embedding hosts, which started to refuse calls near the end and made a few batches wait to be sent again.

The time is now arithmetic: an 18-page PDF costs about 15 to 20 seconds of a worker's time, and the total is that work divided by the CPUs, plus about a minute for the burst to arrive and the path of the last document. More servers, shorter wait; the ceiling is how many servers the cloud account may run at once, not the design.

Big files

Cut by size, not by chapter.

Ten-page parts tame a long PDF. Other files are big in other ways: a CSV of 25 million rows, a text with no heading at all, a web page of 200,000 sections, a Word file that is mostly photographs. Each one has to be cut into jobs a small worker can hold, and the cut must not depend on how the author laid the file out.

So every split goes by size, the way S3 sends a big upload in fixed-size parts. A spreadsheet or a CSV is cut into blocks of cells. A Word file, a web page or a text is cut into blocks of about 4 MB: at a heading when one comes near the limit, at any paragraph once the block is full. A section of a thousand pages is simply several blocks; a file with no headings is cut at paragraphs, then sentences. No step ever holds the whole file: the split streams it, and the join writes the document back a block at a time.

Pictures never count against a block. A Word file keeps its pictures as separate files inside the zip, so a short section with fifty photos is a small block of text plus fifty picture jobs, each reading one photo under its own memory cap. A very large picture is shrunk to about 25 megapixels before it is read. In a Word file too long to read whole, the pictures' text is placed after the body, since the place of each picture in the text is not known without reading the file whole.

When a job still outgrows its worker, it is not the end of the document. A job that dies on its memory cap is sent again to a pool with several gigabytes per job, which only the burst servers serve. The cap is what makes this safe: a job is a child process that is stopped at its limit, so a huge file can kill its own job but never the server next to it.

FileHow it was cutResult
CSV, 934 MB, 25 million rows1,251 blocks read, 1,250 ranges cut into passagesevery memory-bound step done within the hour
Text, 476 MB, no headingsblocks at paragraphs; the cut outgrew a worker and ran again with more memorycut into 2,433 ranges
Web page, 204 MB, 200,000 sections52 blocks, 1,038 ranges, 3,089 embedding batchessearchable
Word, one section of 30 photos of 6,000 px (131 MB)one small block, 30 picture jobssearchable, a word printed in a photo found
Word, 12,000 chapters (21 MB of text) with photosblocks of 4 MB, a job per photosearchable, a word printed in a photo found
Picture, 20,000 x 20,000 pxshrunk to about 25 MP, then readsearchable

Measured on our servers, 19 November 2026. For the two largest files the slow part left was embedding: about 400 million tokens of small calls to the embedding hosts, a bill and a wait rather than a memory problem.

When a file is bad

A bad PDF costs one job, not a worker.

The workers read what people upload, and some of it is broken, huge or hostile. The design keeps each such file to the one job that touches it.

  • Sandboxed. Each job on an uploaded file runs in a child process with capped memory, capped CPU time and an empty environment.
  • No storage key on a worker. A job carries signed links that open one object each, for a few hours.
  • Nothing lost. A job is acknowledged only after its answer is sent, so a dying worker's job goes to another. Queues and messages are written to disk. The orchestrator's own progress is checkpointed too (next section).
  • Never on the web server. A document the fleet could not take is tried again, four times over about five minutes, so a busy or restarting server does not fail it; then it is marked failed, never read on the small server that serves the site.
  • Burst servers locked down. From boot their firewall accepts only the private network, SSH is off, and the worker runs unprivileged on a read-only filesystem.
  • The weak spot. There is one broker. If its disk dies, waiting jobs are lost and must be sent again; the documents themselves are safe in storage.
When the orchestrator stops

A deploy halfway through an upload resumes, it does not start over.

The queue protects the workers: a worker that dies leaves its job to another. Nothing protected the orchestrator. It is a process in the web server, and it kept each document's progress in memory: which parts went out, which came back. A deploy or a crash in the middle of a big upload threw that away, and every document still being read started again from its first page.

So each document is now a durable workflow. We use DBOS, an open-source library that records a workflow's steps in Postgres. We already run Postgres, with a replica, so this adds no server; if Postgres does not answer, documents are read the old way. Every answer a worker sends back is a checkpoint: one per 10-page part, one per embedding batch, one per store batch. When the orchestrator starts again, it reads its checkpoints: what was answered is taken from there, and only the parts still out are sent again.

Three details:

  • The right size of checkpoint. A 10-page part, not a passage or a row: a 400-page PDF is 53 checkpoints, few enough to cost nothing, small enough that a restart loses at most the parts in flight.
  • Two web servers. Each one writes a heartbeat. A server that stops writing for 90 seconds, replaced by a deploy or gone for good, has its unfinished documents taken over by the other.
  • The same file sent twice is read once. A workflow is named after the session, the file's name and its contents: sent again, it joins the first reading or takes its result.
A 400-page PDF (40 parts), orchestrator killed with no warningResult
Killed after27 s, 16 of 40 parts done
Parts sent again after the restart24: the ones not done. None of the 16 done.
Killed, restarted and finished71 s, against 67 s without the kill
What it storedthe same passages and vectors as an uninterrupted run
Cost of the checkpointsabout 5% (median 51 s against 49 s), inside the run-to-run spread

Measured 25 November 2026 on a test setup: RabbitMQ, an S3 store, Qdrant and Postgres in Docker on a laptop, one worker process, the orchestrator in a process of its own, killed with no warning. The cost compares three runs of each kind, alternately, after a warm-up; DBOS's start-up, once per process, is left out.

And a million?

The reading is a bill, not a wall.

A million 18-page PDFs is about 15 million worker-seconds, some 4,000 worker-hours. With 1,000 workers, about four hours. Servers are billed by the hour they run, so ten times the servers costs about the same and finishes ten times sooner. That part is an estimate from the runs above, not a measurement.

What does not grow on its own is everything the workers share. At that rate the single storage server, the embedding hosts and the vector database become the pace, and each needs to grow with the fleet: more storage nodes, more embedding capacity, more database shards. The next run, 10,000 documents, is there to find which one gives first.

Take the document apart, pass pointers, let the next free worker take the next job, and start while the files are still arriving. 1,000 PDFs: searchable 3.4 minutes after the first byte.

Try it on your own documents.

Try it on your documents

Published 18 November 2026, updated 25 November 2026 (durable workflows) · Philippe Vergnet, VectoGrid