One job waiting, four servers idle, and none can run it How we scale document ingestion with RabbitMQ and Ray.
- A 200,000-row spreadsheet needed 3 GB of memory and almost five minutes of CPU to read. It does not fit a worker on our four everyday servers, even when all four are idle.
- So there are two reasons to start a server: many jobs waiting, or one job that needs more room.
- A small controller decides when to start servers, and deletes them once no job has been waiting or running for 2 minutes.
- RabbitMQ delivers the jobs. The new servers form one Ray cluster, and Ray places each job on a server with the CPU and memory it asks for.
- Ray books GPUs the same way. We do not use any yet; if we host our own embedder or speed up OCR, a GPU server joins the same cluster.
The companion to How we ingest thousands of documents in minutes, which explains the jobs and the queue.
Too big for a small worker.
A 200,000-row spreadsheet took almost five minutes of CPU and 3 GB of memory to read. Each job on our four everyday servers runs under a memory cap sized for a small server, and this one went over it. The queue was otherwise empty and all four servers were idle, and we still needed another machine.
Sizing every everyday server for the largest file would make every server expensive, for a file that comes once in a while.
The other reason is the familiar one. VectoGrid reads documents as small jobs on a shared queue, and any free worker takes the next job (how and why). For a few documents at a time, four servers are plenty. A zip of a thousand documents wants many more CPUs, for half an hour, then none.
So there are two reasons to start a server: many jobs waiting, or one job that needs more room. Three pieces share the work. A controller decides when servers come and go. RabbitMQ delivers the jobs. Ray places each job on a server with what it asks for.
Watch the queue, start servers, give them back.
A small controller runs on one of the fleet servers. It is the only program that holds the cloud account's token. Every 10 seconds it reads how many jobs are waiting, and how many have been taken and are still running.
- Start. Once 40 or more ordinary jobs are waiting, or a single large-file job, it asks the cloud provider for servers: about one per 64 waiting jobs, ten at most.
- Fast boot. Each server starts from a ready-made image that already holds the worker, so there is nothing to install. Measured: the new servers were taking jobs 30 seconds after the controller asked for them.
- Stop. When no job has been waiting or running for 2 minutes, the burst servers are deleted; a server 2 hours old is deleted regardless. Running counts: a queue only reports the jobs still waiting, so a long job, once taken, would otherwise see its server deleted under it and start over on the next one.
- The bill. Servers are billed by the hour they run: at the same hourly rate, 30 servers for one hour cost as much as 3 servers for ten.
| RabbitMQ queue | Who takes the job | What starts a burst |
|---|---|---|
| Ordinary jobs | The always-on workers and, during a burst, the readers on the Ray head | 40 waiting jobs |
| Large-file retries | Only the readers on the Ray head | 1 waiting job |
The queue sees readers. Ray sees CPUs.
The burst servers form one Ray cluster. Ray is an open-source framework that runs Python functions, called tasks, across many machines: you say what a task needs, one CPU, so much memory, and Ray starts it on a machine where that is free.
The first burst server is the cluster's head. It runs one queue reader per CPU in the cluster, up to 64, and adds readers as servers join. Readers on the Ray head take ordinary jobs from the shared queue and large-file retries from a separate queue, one job at a time, and submit both to Ray as tasks. Ray runs it on whichever server has a free CPU, and runs it again if that server fails, twice at most.
Why not simply start the same worker on every burst server, each reading the queue on its own? For ordinary jobs that would work. Ray earns its place with the next two sections: it places a job by what it needs, memory today and GPUs if it comes to that, and the servers come and go inside the cluster while the queue only ever sees the head's readers.
A big file gets a big slot, not a big fleet.
Most jobs are small: ten pages of a PDF, a chunking, a batch of embeddings. Some are not. A file that cannot be split into pages is read whole: a huge spreadsheet, a very high-resolution scan, a very long document's chunking. Such a job can outgrow the memory or CPU-time cap of a small slot.
- Tell big from broken. When a job dies, the orchestrator reads why. A broken file fails and is reported. A job that ran out of memory or CPU time is a big file, not a bad one.
- Send it again, asking for room. The big job goes back on a queue of its own, now asking for 6 GB of memory and up to 30 minutes of CPU. Only the Ray readers take from that queue.
- Ray books the memory. The task tells Ray it needs 6 GB, and Ray starts it only on a server where 6 GB is not yet booked by other tasks. An ordinary job books its small slot, so a 6 GB job and the small ones share a server without being placed beyond its memory.
- The job enforces its own limit. Booking is how Ray chooses a server; it does not stop a task from using more. The cap does: the job runs in a child process limited to 6 GB of memory and 30 minutes of CPU.
- One big job is enough to start a burst. The always-on servers never take big jobs, so the controller starts burst servers as soon as one is waiting, even if the queue is otherwise quiet.
The alternative was a pool of large servers kept for the occasional large file. With Ray, the large file borrows room on the same burst servers that read everything else, and only while it runs.
GPUs join the same cluster.
Ray books GPUs the way it books memory: a task can ask for one, and Ray starts it only on a machine that has one free. That keeps two future changes small.
- Our own embedder. Embedding today is a call to a hosted model, and the provider's rate limit sets its pace. Embedding on a CPU is far too slow for bulk reading; a GPU is fast enough, and the passages never leave our servers.
- Faster OCR. Scanned pages are read by OCR on CPUs today. A GPU can read the same pages faster.
Either way, a GPU server joins the Ray cluster like any burst server. The embedding or OCR jobs ask for a GPU and land on it; everything else stays on the CPUs; the queue and the jobs do not change. We have not built this yet: hosted embedding and CPU OCR keep up today. The point is that the day they do not, it is a server to add, not a pipeline to rewrite.
A public address, and a cluster that must stay private.
Our Ray cluster runs without a password of its own: anything that reached its ports could run code on it. So at boot, each burst server restricts access to the private network before starting Ray.
- Private network only. The first thing a burst server does at boot is set its firewall to accept the private network and nothing else.
- No way in. The root password is locked and SSH is turned off. A burst server sends its own startup log to storage, the only way to see inside it.
- No privileges. The worker runs in one container with no privileges, a read-only filesystem and capped memory, and every job still runs in a capped child process with an empty environment.
- No cloud token. Only the controller can create or delete servers. A burst server holds no key that could start another.
Try it on your own documents.
Published 17 November 2026 · Philippe Vergnet, VectoGrid