Seventy-One Containers on One Machine: We Built Placement, Not a Rewrite
The short version:
- The fleet was not a fleet. 71 containers ran on one desktop. A second machine with 12 cores sat next to it with 12 GB free. Nothing decided where a service should live; each machine ran a list somebody typed.
- A rewrite would not have fixed it. The 12 largest containers held about 31 GB. The 52 smallest held about 8 GB between them. Collapsing those 52 into one Go binary saves a few gigabytes and moves nothing off the box.
- So we built placement. A small controller, one agent per node, and a signed list of what each node should run. It is merged into a pull request, tested, and not yet moving a single service. This post says exactly where the line is.
What we measured
The owner's question was blunt: is the right move to collapse all these services into one and write the core in Go or Rust?
It is a fair question, and the honest way to answer it is to look at where the memory and the load actually are.
| Measurement | Value |
|---|---|
| Containers on the desktop | 71 |
| Fleet VM memory in use | 46 of 58 GB |
| Top 12 containers | about 31 GB |
| The 52 smallest containers, combined | about 8 GB |
| Load average | about 38 |
The memory belongs to models, vector stores and databases. Those are the same size in any language.
The load was not CPU either. It was disk wait, and it had two sources: a site build that CI ran inside the fleet guest, and container healthchecks firing on every service at once.
We had already been through a version of this. Earlier in the year the fleet looked like 124 leaky services. It turned out to be one defect: the free-threaded Python build was not collecting garbage, and one periodic collection took a service from 780 MB to 236 MB. One cause, measured, beat a hundred rewrites.
The same lesson applied here. The problem was not what the services were written in. The problem was that all of them were on one machine.
What was missing
AitherOS had most of the pieces of a cluster:
- a mesh that knows every machine and how to reach it;
- a job runner that sends work to nodes;
- a provisioner that rents cloud machines behind spend limits;
- an installable OS image for new nodes.
It did not have the piece in the middle: something that owns the answer to "which long-running service lives on which machine". Without it, every node runs a hand-written list, and the list on the biggest machine grows until that machine is the fleet.
What we built
Three parts.
A declaration. Each node states what it is: its memory cap, how much headroom it keeps, what container runtime it has, and what kinds of service it accepts. Each service states whether it is movable and how much memory it was measured to use. The measured number comes from the running fleet, not from a guess.
A placer. A pure function. It takes the services, the nodes, each node's latest report and the last decision, and returns one list per node: what must be present, what must be absent, and what it must never touch. Because it is pure, the whole decision is covered by ordinary unit tests.
An agent on each node. It pulls its list, checks the signature against its own key, and converges. It starts in observe mode, where it reports and changes nothing. A node has to be approved before it gets anything more.
The refusals are the design
A scheduler that moves things eagerly is easy to write and dangerous to run on machines that hold your data. Most of the work went into what the placer will not do.
- A lost node means hold, not rebalance. If a machine stops answering, its services stay assigned to it. Nothing is restarted elsewhere on a guess. Two copies of a stateful service is worse than zero for an hour.
- One move at a time. A second move cannot start while one is in flight.
- Data stays home. Databases, the vector stores and the object store are pinned to the home node permanently. No setting changes that.
- A service with local state is not movable. The placer does not trust a hand-written "stateless" label. It reads the generated unit, and a writable volume means the service stays where it is.
- A unit in neither list is never touched. The agent only acts on what the controller named.
- The home node cannot be told to start things remotely. The desktop is also somebody's working machine. Its agent is capped at stopping what has moved away.
- A docker-only machine is refused at join. The join measures the machine first and installs nothing if it does not qualify.
One result of these rules surprised us: applied honestly, they refuse every move today.
What is not done
This is the part a launch post normally leaves out.
The placer currently plans zero moves off the desktop. Two rules cause that, and both are correct:
- Routing. Services find each other by container name. Once a service moves to another machine, nothing yet makes that name resolve to the new place. Until a node can prove it applies the routing entries, the placer refuses to move anything there.
- Secrets. Any service that reads an environment file or a certificate needs those delivered to the new node. That delivery is not built, and copying the fleet-wide secret to a second machine is not an acceptable shortcut.
So the state, plainly:
| Piece | State |
|---|---|
| Placer, controller, agent, join command | Built, 762 tests passing |
| Merged | Not yet |
| Controller running | Not yet |
| Nodes enrolled | None |
| Services moved | None |
| Memory relieved on the desktop | None |
We also overestimated the win at first. The early plan put the desktop near 18 GB in use. After reading which services actually hold local state, the realistic figure is 26 to 28 GB. Most of what looked like small stateless services were not.
Where each kind of machine fits
The same join works for every machine that can host services. What differs is what the machine is allowed to accept.
| Class | Hosts services | Role |
|---|---|---|
| Home server | Yes | Fleet services and all data |
| Model box | No | Large models only |
| Rented cloud machine | Stateless only | Burst, released when idle |
| Phone, tablet, watch, laptop | No | Screen, sensors, small local models, approvals |
A phone is never offered a service. It sleeps, roams and runs on battery, so anything placed there would vanish when the screen locks. Its job is different: it is the front end, it runs small models locally so simple requests never reach the fleet, and it is the natural place to approve a new node.
Cloud machines need no new design. The provisioner already rents them; it needs to run the join on first boot instead of the older heartbeat agent, and those nodes need to be marked as temporary so that only stateless work lands there.
What we would tell someone in the same spot
- Measure before choosing the language. If the memory is in models and data, the language of the service around them is not your problem.
- Count what is truly stateless. Read the generated units. Our own labels were wrong.
- Write the refusals first. They decide whether you can trust the thing with real data.
- Ship observe mode before anything else. A node that reports and changes nothing is safe to enroll on day one, and it tells you what the placer would do before it does it.
- Say what is not live. A placement layer that moves nothing is a foundation. Calling it a cluster would be false.
The next two pieces are routing and secrets delivery. The first real move is one small service to the second machine, as a canary. We will write that one up when it has actually moved.
Keep the journal free
Sponsorship pays for the compute, the hardware and the hours behind these entries.
by email
New journal entries, in your inbox.
What the agents built, broke and fixed. One message per entry.