sbarbase
Contents

Isolation and trust

What it is

Each environment gets its own database, its own service logins and its own keys, so an app's users and tokens cannot reach another environment. Some parts are deliberately shared (the PostgreSQL engine, Storage, the gateway and the host), and anything shared is a place where one environment's failure can affect the others.

Why

Choice: trusted operators, untrusted app visitors. The people who run the server and write SQL for its environments are trusted. The visitors of the apps, with their anonymous or signed-in tokens, are not. This matches the primary user (one developer or agency running apps for their own clients) and keeps the design honest about what it defends against.

Rejected alternative: hostile multi-tenant hosting. Selling space to mutually hostile customers would require isolation from the operator and from arbitrary SQL, which a shared PostgreSQL engine cannot give. Anyone who needs that should run independent stacks.

Choice: separate credentials, not only separate schemas. Separation by schema inside one database would leave every environment behind the same Auth and the same API roles. A database per environment, with its own logins and connection rules that allow exactly one login to reach exactly one database, keeps a leaked service credential inside its environment.

How we built it

Untrusted app visitors reach the server only through the TLS proxy and the gateway with a publishable key; trusted operators use the console or the host directly; each environment has its own Auth, REST, database and logins, while the PostgreSQL engine and Storage are shared failure boundaries

Only the TLS proxy faces the network; the engine and Storage are shared failure boundaries.

A request with project A's key on environment A's path reaches A's REST and database A; the same key on environment B's path gets 401 at the gateway; and a login that tries another environment's database is refused by PostgreSQL's connection rules

No data mixing: A's key, tokens and logins open only A's database.

A burst on environment A fills its guaranteed 8 gateway slots and borrows idle ones up to its ceiling of 24 of the gateway's 64, so environment B is still admitted at once and A's extra requests get 429; behind the gateway each environment has its own containers with CPU, memory and IO limits, and its own connection limits in the shared engine

A busy environment uses the idle server, but never the share its neighbours need. The limits are not calibrated under sustained load.

What is separate per environment:

What is shared, and therefore a shared failure boundary:

Code: lab/resource_policy.py (tiers), lab/resource_admission.py, lab/pressure_admission.py and lab/connection_budget.py (admission), lab/hba_authority.py (connection rules), src/gateway/handler.ts (key checks).

Limits

Go deeper

Edit on GitHub