Ground Zero
Letting the monolith storage architecture go.
We’re close to launching a SaaS with a feature that lets anyone make short-form videos just by chatting with AI. It runs on Railway, it serves 33 active test users, and before launch it has to run on more than one replica. Right now it can’t.
That’s a choice I made, not an accident. One container with one volume was the fastest path to a working product: Railway’s abstractions took the infrastructure off my plate while I built the agentic features, and at that stage features were the risk, not scale. The cost of shipping that fast is that you lose track of how reliable the storage architecture is.
This post is about paying that cost: how we store the image and video data the service generates, and what has to change before real customers arrive.
०१Where we are today
Today, the web service does 3 jobs in one container:
- Holds the database: an SQLite file in the volume.
- Holds every video: uploads → takes → renders, in the same volume.
- Runs heavy work: renders run inside the web process as well.
streams every video byte
ffmpeg · Remotion · whisper
SQLite + every video
one mount at a time
Python
backend only
Everything the web knows sits on one disk that only one deployment can mount. A Railway volume can be mounted on one deployment only, so that means:
- One replica only
- No failover
- A short outage on every deploy
- Limited render capacity
And every video byte a viewer watches in the app is streamed through the web service, which costs egress and memory.
०२The change I made before launch
The change is simple yet effective: no service owns a disk anymore. State lives in Postgres and a bucket, which every replica reaches over Railway’s private network, so the web and the worker can each run more than one copy. The rest of the backend doesn’t change.
no volume · checks owners
rows + job queue
all media · free egress
ffmpeg · Remotion
presigned links
SKIP LOCKED
a)Single-attach block storage
A volume is a virtual hard drive attached to one machine (on AWS that’s EBS). If two replicas each had their own copy, the copies would drift apart after the first write: user A uploads to replica 1, and replica 2 never sees the file.
- Files → object storage (a bucket). Files are stored under keys like
projects/123/video.mp4and fetched over HTTP. Any number of machines can read and write them. On AWS this is S3. - Rows → a shared database server (Postgres). It handles concurrent writes from many clients properly, which SQLite can’t do across machines.
b)Non-durable in-process jobs
A job runs as a JavaScript function inside the web process with setImmediate. This causes two problems:
- Another machine can’t pick the job up, because a function in memory can’t be sent anywhere.
- If the process crashes or redeploys, the job silently disappears. Nothing sweeps jobs left as “running”, so the user just sees a render stuck forever.
c)Process-local singletons
Several things live only in the web process’s memory:
- the publish scheduler (a
setIntervalevery 30 s) - a couple of background sweepers
- a few counters that need to be the same on every copy
With two replicas, both schedulers would post the same scheduled post twice, and each replica would only see its own half of those counters.
०३What it costs
| Item, per month | Change |
|---|---|
| Render CPU moves to the worker, same amount | 0% |
| RAM more services running | +25% to +50% |
| Media storage, 200 GB volume → bucket | −90% |
| Video egress, ~600 GB bucket egress is free | −100% |
| Hosting total | −60% to −68% |