A sandbox per tenant
Three steps make a multi-tenant product. 1. Build the tenant image once. Create a machine, install your agent harness on it the way you would on any Linux box, and save it as a snapshot. Hermes is one example of a harness, and/boxd-setup-hermes installs it for you (see its setup):
isolated set so tenants can never reach each other or the rest of your fleet:
- TypeScript
- Python
agent-harness-v1 means the same environment for every tenant, and rolling out v2 is a new snapshot rather than a migration. New tenants get it immediately, and existing tenants get it on their next recreate.
Account-level env vars and secrets reach your own machines, and isolated machines deliberately receive none of that account state. For tenant sandboxes, per-tenant secrets therefore go in through code at create time, as above.
A fleet that is mostly asleep
Most tenants are idle most of the time, and boxd’s lifecycle model is built for exactly that. A machine with no inbound traffic hibernates automatically, costs effectively nothing while asleep, and wakes in about 85ms when the next request hits its URL. The caller can’t tell it was ever off. For tighter windows, enable auto-suspend and the machine resumes in sub-millisecond time:Serve it under your domain
Tenant machines can live under your brand instead ofboxd.sh. Delegate one wildcard subdomain to your org and every machine, current and future, gets a name under it:
tenant-42 answers at https://tenant-42.vms.mysaas.com with TLS issued automatically. For a single flagship app you can also bind one specific domain to one machine. See Custom domains.
Keep tenants apart
Every machine is hardware isolated, so one tenant’s code can never read another tenant’s memory or disk. On top of that, theisolated flag in the example above is the strictest network setting: a tenant sandbox reaches none of your other machines, ever, beyond networks you grant it explicitly. See Sandboxes.
Two softer arrangements exist when tenants should cooperate:
- Machines without the flag share your account’s private network by default, which suits a fleet that works together.
- Network labels partition per tenant, so machines within one tenant reach each other while tenants stay apart. Isolated sandboxes never reach each other even on a shared network, so a tenant that needs several cooperating machines uses labels without the flag.