When you host one website, architecture barely matters. When you host thousands — free sites, paid sites, custom domains — every decision gets multiplied. These are the patterns that have held up for me.

Request flow

Every request starts with one question: which tenant is this?

custom domainsubdomainyesnoVisitorEdge / CDNHost headerDomain map lookupSlug from subdomainTenant IDCached?Serve from edgeOrigin renders pageObject storage

Resolving the tenant at the edge means the origin almost never sees traffic for a page that hasn't changed.

Three rules for tenant isolation

  1. Tenant ID on everything. Every row, every storage key, every cache key. No exceptions, no "global" shortcuts.
  2. Separate free from paid. Different hostnames for freemium and custom-domain sites lets you apply different limits, caching and abuse rules without branching code.
  3. Immutable versions. A publish writes a new version; the domain just points at it. Rollback becomes a pointer change.

Publishing as a pointer swap

publishpoint domainrollbackDraftVersionLive

Because versions never mutate, the cache can be aggressive. Invalidating one tenant's site is a single purge by tag.

What I'd tell my past self

Multi-tenancy isn't one big decision. It's a hundred small ones that all say: this belongs to exactly one customer.