I run a multi-tenant product on a shared EKS cluster with a shared database. Tenants are separated at the application layer using a tenantId, and each request can be associated with a tenant through its domain or request headers. I can measure overall AWS and service costs, but I'm struggling to produce a defensible per-tenant breakdown. My current idea is to use Kubecost for service and pod costs, allocate shared service costs according to each tenant's request volume, attribute CDN and data-transfer costs using bytes per tenant domain, and divide database costs based on tenant-specific row or storage usage. How would you approach this? Does the allocation need to be highly precise, or is a consistent usage-based estimate usually more practical?
5 Answers
Keep a usage ledger for each billing period. Record tenant-associated events in a queryable store, such as tables in object storage, and reconcile those records with the AWS bill and container-level metrics. This lets you produce repeatable estimates and revise the allocation model later without needing to redesign the whole platform.
If you need strong tenant-level accuracy, isolate more resources by tenant. Dedicated databases or other tenant-specific AWS resources can be tagged and billed directly, although that increases operational overhead and may not be practical for every customer. With an application-level tenantId in one shared database, some custom metering and allocation logic is unavoidable.
Your approach is reasonable as a starting point, but request count alone may not represent actual resource consumption. Add the tenant ID to traces and usage records, then track things such as request duration, CPU or compute intensity, database query time, rows scanned, storage, and transferred bytes. Use those measurements to build a cost-to-serve model and document the assumptions behind each allocation.
Treat this as a cost-allocation problem rather than something AWS can solve automatically. Separate costs that can be attributed directly from shared overhead. Tenant-specific egress, storage, and domain traffic can usually be mapped fairly well, while EKS capacity, database CPU, caching, monitoring, and idle headroom need allocation rules based on measurable usage. Use different drivers where appropriate instead of applying request percentage to everything.
First decide how accurate the number needs to be. For internal pricing or forecasting, total infrastructure cost divided by a representative usage metric may be enough, especially if the resulting rate is rounded and kept stable for a period. Trying to calculate every shared dollar precisely can create a lot of complexity without producing a more useful business decision.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures