Multi-tenant SaaS Platforms — Cells, Rings & Progressive Delivery›15 · Customer tenant lifecycle

Lesson 15 of 16 · Tenants: isolation and onboarding

Customer tenant lifecycle

What happens when a customer company signs up, changes plan and leaves. The manual steps (tenant record, placement in a cell, data and keys, identity with single sign-on to the customer's own identity provider, plan limits, routing, metering, verification), how authentication and quotas work on every request, and how to automate the whole lifecycle with a workflow of idempotent steps that can be retried or undone.

Advanced
Key wordscustomer onboardingtenant lifecycleSaaS control planetenant catalogplacementworkflow engineidempotent stepscompensationsagaSSO federationSAMLOIDCSCIMorganizationtenant_id claimplan limitsrate limit per tenantusage meteringplan changeoffboardingdata exportcrypto-shredding

A customer is not a namespace

In lessons 13 and 14 the tenant was an internal team getting a namespace. In a SaaS product, a tenant is a customer company. It usually doesn't get a namespace: it gets a record, data, an identity setup and limits inside a shared cell (or a dedicated cell, lesson 8). The services that do this make up the SaaS control plane (lesson 11).

POST /tenants {name, plan, region} Record 1 Place 2 Data + key 3 Identity 4 Limits 5 Route 6 Meter 7 Verify 8 failure: retry the step, then undo finished steps in reverse status: active every step idempotent: safe to run twice
One sign-up starts a workflow in the control plane; each step is retried safely, and finished steps are undone if the tenant can't be completed.

A new family joins a sports club. The office writes their card (record), picks a changing room with free lockers (placement), gives them keys (identity), explains what their membership includes (plan limits), tells the front desk which room is theirs (routing), and starts the monthly bill (metering). If the club runs out of lockers halfway, the office takes back the keys and tears up the card, instead of leaving a half-member.

Manual steps (what an operator would do by hand)

# Step Details
1 Tenant record Tenant ID, company name, plan, home region, contract limits, status provisioning
2 Placement Choose a cell in the home region with capacity (lesson 2), or create a dedicated cell
3 Data and keys Create the tenant's rows or schema in the cell's database; create a per-tenant key (lesson 12)
4 Identity Create the tenant as an organization in the platform's identity provider; set up single sign-on with the customer's own IdP (SAML or OIDC); invite the first admin; optionally SCIM to sync users
5 Limits Load the plan's limits: API rate per tenant, number of users, storage, concurrent jobs
6 Routing Write tenant → cell into the routing catalog (lesson 3); create acme.app.example.com if you use per-tenant hostnames
7 Metering Start usage events and billing for the plan
8 Verify and activate Sign in as a test user, call the API, check that limits apply; set status active; send the welcome email

Doing this by hand works for the first ten customers. After that it becomes slow, inconsistent and a source of incidents.

Sign-in and limits on every request

User at Acme ──► Acme's identity provider (SSO) ──SAML/OIDC──► platform IdP
                                                                    │ issues a token
                                     { sub: "ana@acme.test", tenant: "acme", plan: "standard", ... }
                                                                    ▼
API gateway   verify signature → tenant + plan from claims → rate-limit bucket "acme" (standard plan)
              too many requests → 429 Too Many Requests + Retry-After
                                                                    ▼
Cell router   acme → cell-07
                                                                    ▼
Services      every query scoped to the tenant (row-level security, lesson 12)
              plan limits checked: users, storage, jobs → clear error when over the plan
  • Federation: your product trusts the customer's identity provider for sign-in; the customer's IT controls passwords, MFA and leavers.
  • SCIM creates, updates and removes the customer's users and groups in your product automatically, so a person who leaves the customer also loses access to your product.
  • Limits are data in the tenant record, read by the gateway (rate) and the services (counts, storage), never hard-coded. The gateway part is built hands-on in Rate limiting and quotas: free and standard tenants with different limits, enforced per tenant from the verified token.
Plan (example) API rate Users Storage Isolation
Free 5 requests/s 10 1 GB Shared cell
Standard 50 requests/s 1,000 50 GB Shared cell, own key
Enterprise 500 requests/s 100,000 1 TB Shared cell or own database, customer-managed key, SCIM
Dedicated By contract By contract By contract Own cell

The numbers are only an illustration; the principle is that a plan is a row of limits, applied in the same places for every tenant.

Automating it: a workflow, not a script

A workflow engine in the control plane (for example Temporal, AWS Step Functions or Argo Workflows) runs the steps from one API call or the sign-up page:

POST /tenants {name: "Acme", plan: "standard", region: "eu"}
  │
  ├─ 1 create record ............. idempotent: "create if not exists" by tenant ID
  ├─ 2 place in a cell ........... reads capacity; reserves a slot
  ├─ 3 create data + key ......... safe to repeat
  ├─ 4 set up identity ........... organization, SSO metadata, admin invite
  ├─ 5 load plan limits
  ├─ 6 publish routing entry
  ├─ 7 start metering
  └─ 8 smoke test → status active
on failure: retry the step (with backoff); if it still fails, compensate 7 → 1 in reverse
            (remove routing, delete data and key, release the slot) and set status failed + reason
Rule Why
Idempotent steps A retry after a timeout doesn't create a second database or a second key
Compensation (a "saga") No half-created tenants; every finished step has an undo
Visible status Support and the customer see provisioning, active or failed: reason
Timeouts per step A stuck identity call doesn't block the whole workflow forever
Same workflow for dedicated plans One extra step: create a cell from the blueprint using the fleet automation
Target time Minutes for shared plans; the customer can start right after sign-up

The rest of the lifecycle

Event Steps
Plan upgrade Update limits in the record; the gateway and services pick them up; for an isolation change (for example own database), run a tenant move (lesson 4)
Suspension (unpaid, abuse) Block sign-in and API at the gateway; keep data; resume restores access
Region change A tenant move to a cell in the new region, with residency rules checked
Offboarding Export data if the contract requires it → disable access → delete data in the cell, caches, search indexes and analytics → destroy the tenant's key (crypto-shredding covers backups) → remove routing and catalog entries → keep a deletion record for compliance

Try it: design the workflow

  1. Write the onboarding workflow for your own product idea as a list of steps, each with "how is it idempotent?" and "what is its undo?".
  2. Step 4 (identity) times out after the organization was created but before the response arrived. Walk through what the retry does.
  3. Design the plan table for three plans, and say where each limit is enforced (gateway, service, database, Kubernetes).
  4. Write the offboarding checklist, including every place a copy of the tenant's data might exist.

Going deeper

  • Keep the tenant catalog small and highly available: the routing layer caches it, and the request path must not depend on the control plane being up (static stability, lesson 1).
  • Emit lifecycle events (tenant.created, tenant.plan_changed, tenant.offboarded) so billing, analytics, support tools and cost reports react without the workflow calling each of them.
  • Test onboarding continuously: a synthetic tenant is created and deleted every hour in each region, and alerts fire if it fails.

Recap

  • A customer tenant gets a record, a cell, data and keys, identity with SSO, plan limits, routing and metering.
  • On every request, verified token claims carry the tenant and plan; the gateway limits by them and the services enforce plan limits and data isolation.
  • Automate with a workflow of idempotent steps, compensation on failure and visible status.
  • Plan changes, suspension, region changes and offboarding are workflows too; destroying the tenant's key makes deleted data unreadable everywhere.

This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.