Every site this service hosts is served by code that cannot talk to our API, cannot reach our database, and does not know either exists.
That is a design constraint rather than an achievement, and it is worth writing down because it is cheap to adopt early and expensive to retrofit. The rule is one sentence: nothing on the path of a visitor's request may depend on the system that manages accounts.
Two planes
The control plane is the API: sign-in, quotas, billing, domains, issuing upload URLs, recording what a deploy contains. It runs on a server, talks to Postgres, and has all the usual availability of a thing like that.
The data plane is a worker at the edge. It receives a request for something.example, looks up that hostname in a key-value store, gets back a small record —
{ "siteId": "...", "deployId": "...", "spa": false }— and serves the matching file out of object storage. That is the whole of it. No database connection, no call back to the API, no shared session state.
If the control plane is down, nobody can publish anything new, sign in, or change a domain. Every site that already exists keeps serving, at full speed, with no degradation of any kind — because the request path never included the part that is down.
Go-live is one write
The interesting consequence is what "publishing" has to mean under that rule. A deploy happens in a fixed order:
- Object storage. Upload the files that are new.
- Postgres. Record the deploy: what it contains, who owns it, which version it is.
- The key-value store. Point the hostname at the new deploy id.
Only the third step is visible to a visitor, and it is a single small write. That is deliberate: flipping that mapping is the only go-live action there is. Every earlier step can fail, retry, or be abandoned, and the live site is exactly what it was — because the only thing that decides what is live is a value the earlier steps have not touched yet.
It also makes rollback symmetric. Going back to a previous version is the same single write with an older deploy id in it. There is nothing to rebuild, no files to move, and no window in which the site is half of one version and half of another. Files are immutable and named by content, so the old version's files were never deleted or overwritten to begin with.
Order matters in the other direction too, and this is the part that is easy to get backwards. Writing the mapping before the files exist is a live site pointing at nothing. It is worth being specific about the order in a document, because it is the kind of thing a refactor reorders innocently.
What this costs
Three real prices, and it is dishonest to describe the design without them.
Eventual consistency between the planes. The database and the key-value store can disagree for a moment. The reconciliation is ours to write, and it is the kind of code where bugs show up as "this one site serves an old version" rather than as an exception in a log.
Anything requiring account state has to move to the edge or be given up. Serving a password-protected site means the worker needs the credential — so it is stored beside the mapping, as a salted hash, and the check happens where the request is. Anything we could not express that way does not exist as a feature. That is a constraint on the product, not just on the architecture.
Writes from the edge cannot be synchronous. When a visitor submits a form on somebody's site, the worker does not call the API — that would be exactly the dependency this whole arrangement exists to avoid. It puts the submission on a queue, and a separate consumer, which is allowed to talk to the API, drains it. If the API is down, the queue grows and nothing is lost; what is not available is the part that was never on the request path.
Testing that it is true
A rule like this is only worth having if something checks it, because it is violated by a one-line convenience at three in the morning. Two things do.
The first is that the serving code has no credentials for the control plane. There is no connection string to reach for. That is a weaker guard than it sounds — someone could add one — but it makes the violation a deliberate act rather than an accident.
The second is the test that matters more: two different sites, the same path, different contents, requested alternately, asserting each one serves its own bytes. That is really a test of the cache key, which must contain both the site id and the deploy id. The tempting implementation derives the key from the same helper the code under test uses, and then a mutation that breaks the helper moves the code and the expectation together and the test stays green. We know because we tried it: removing the site id from the cache key survived the whole suite. Two of those assertions now spell the key out literally, and mutating the helper kills them.
The general lesson is smaller than the architecture and applies to everyone: a test that constructs its expectation with the code under test is not a test of that code.
Is this worth it for a small service?
For most applications, no. The split costs you a reconciliation path and a feature veto, and it buys availability during an outage you may be able to simply not have.
It is worth it when the thing you serve is somebody else's content, and the failure mode you are protecting against is not "our dashboard is slow" but "ten thousand sites that have nothing to do with our deployment are offline because of our deployment". Once that is the shape of the risk, the question of which system is on the request path stops being an architecture preference and becomes the product.