advanced 2 min answer

A multi-tenant platform needs to know what each customer costs to serve. What makes this hard, and how is it approached?

cost-allocationmulti-tenancyshared-resourcesattributionsalesforcedesign
Show the full answer Hide the answer

Why it is hard

Shared infrastructure means most cost is not naturally attributable. A shared database serves thousands of tenants; the bill is one number. The same applies to caches, message brokers, application clusters and network transfer.

Compounding it:

  • Fixed costs. Control planes, monitoring and platform teams exist regardless of any individual tenant. Allocating them requires a chosen apportionment method, which is a judgement rather than a measurement.
  • Non-linear consumption. A tenant's data volume may drive index size, backup duration and query cost in ways that no single metric captures.
  • Indirect costs. A tenant with pathological queries degrades others, causing over-provisioning that appears as everyone's cost.

The approach

1. Attribute what is directly measurable. Storage per tenant, request counts, compute time where requests are traceable, egress where it can be attributed. This usually covers a meaningful fraction and is the foundation for everything else.

2. Apportion shared costs by a driver, chosen deliberately and stated openly. Database cost by query time or by rows, cluster cost by CPU seconds, cache cost by key share. The driver should be the thing that causes the cost, and the choice should be documented — because it will be argued about, and an undocumented apportionment is indefensible.

3. Report fixed platform costs separately, rather than smearing them across tenants. A per-tenant number inflated by an arbitrary share of platform overhead is not useful for decisions.

4. Instrument the expensive dimensions. Per-tenant database time, cache occupancy, connection pool share, queue time. This serves cost allocation and noisy-neighbour diagnosis — the same instrumentation answers "who is causing it" and "who is affected", which are frequently different tenants.

5. Accept approximation and be explicit about it. A cost model accurate to within a reasonable margin, consistently applied, is decision-useful. Pursuing precision produces a model nobody trusts and everyone argues with.

What the numbers are for

Different decisions need different precision:

  • Pricing and packaging need to know which segments are unprofitable — relative accuracy is enough.
  • Identifying outliers needs only ranking: which tenants cost far more than their tier implies.
  • A tenancy promotion decision — moving a large tenant to dedicated infrastructure — needs a genuine marginal cost, which is the hardest number and the one worth investing in.

The architectural feedback

Persistent cost outliers are frequently a tenancy signal rather than a pricing one. A tenant costing an order of magnitude more than its tier implies is usually one that has outgrown shared infrastructure, and the answer is a dedicated tier with commensurate pricing rather than a subsidy nobody decided to give.