Tenant cost allocation
Understanding customer profitability is crucial for a successful SaaS company. While revenue per tenant shows you what you're bringing in, you also need to know what each customer costs. Calculating the cost per tenant gives you a clearer picture of your profitability, which is essential for making informed decisions about product development and scaling your business effectively.
This is where tenant cost allocation becomes vital. By tracking the resources and costs associated with each customer in a multi-tenant environment, you get a powerful tool for transparent billing and intelligent cost management. Let's look at some examples of how tenant cost allocation helps businesses succeed.
Why calculate cost per tenant
To ensure profitability at the tenant level. Imagine you have two customers. One customer uses your service sensibly and makes it profitable, while another abuses it, costing you more than it pays. While you might be profitable on average, there's a good opportunity to build smarter pricing strategy.
To drive scaling decisions. Tenant cost data shows which customers or features are pushing infrastructure growth. These insights help engineering teams prioritise optimisations and help leadership forecast capacity more accurately.
To improve financial reporting. By focusing on unit economics you show a clear understanding of your SaaS business's financial health. This transparency provides internal and external stakeholders with a clear view of costs, which supports better budgeting and more effective strategic financial planning.
There are two main strategies for cost allocation: coarse-grained cost allocation and fine-grained cost allocation. Let's consider both of them.
Coarse-grained cost allocation
Coarse-grained cost allocation is used to roughly allocate the cost of shared resources to specific tenants. It's a less invasive approach than a fine-grained approach and relies on a simple metric, such as the number of active users, to calculate cost-per-tenant.
Advantages:
- The primary advantage is simplicity. Coarse-grained allocation is much easier to set up and manage because it doesn't require tracking of every single resource.
- Because it's less complex, coarse-grained allocation has a lower cost and operational overhead.
Limitations:
- Less accurate than fine-grained allocation because it relies on high-level service usage rather than precise consumption metrics.
- Complex architectures consisting of diverse services with different pricing models make it difficult to allocate costs using a simple metric like the number of users, especially in case of service usage patterns are different for different tenants.
To implement coarse-grained cost allocation, you need to (1) choose a usage metric for your estimation, (2) estimate tenants usage costs based on that metric, and (3) benchmark your estimates against actual costs to ensure they are accurate enough.
One way to create an effective usage metric is to tie it directly to your pricing model. For instance, you could base it on the number of active users, storage used, or the number of transactions.
Then you need to divide your total cost by the total usage to calculate your cost per use: cost_per_use = total_cost / total_usage
. For example, if your application’s total monthly cost is $100,000 and you have 100 active monthly users, your cost per user will be $1,000 per month. So, if one tenant has 10 users and another has 30 users, their estimated allocated costs will be $10,000 and $30,000, respectively. Simple, right?
But this is not the end. You need to regularly benchmark your estimates to ensure they predict costs accurately. While you can initially use historical data to validate your choice of metrics, this doesn't guarantee they'll work well in the future. That's why you need a feedback loop to track how your estimates deviate from real-world data over time.
The above demonstrates the simple example of considering your whole service as a “black box”. To improve accuracy, you can break your service down into several blocks and apply different metrics to each. For example, you might use the number of support tickets to allocate the cost of the customer support subsystem, and the number of API calls to allocate the cost of the rest of the system.
Fine-grained cost allocation
Fine-grained cost allocation distributes shared infrastructure costs accurately across tenants in a multi-tenant environment. It uses allocation tags and usage metrics to track and attribute each tenant’s actual consumption.
Advantages:
- It provides a much better understanding of the cost per tenant, which is necessary for calculating the Cost of Goods Sold (COGS).
- This level of detail helps the product, sales, and finance teams make better decisions about pricing, feature development, and customer segmentation.
Limitations:
- Implementing fine-grained cost allocation incurs higher upfront and operational costs due to the complexity of tagging, instrumenting, and reporting each resource.
The foundation of fine-grained cost allocation is a comprehensive tagging strategy. Tags are metadata labels you can apply to your resources. For multi-tenant SaaS environments the Tenant
tag is essential. It can have the following values:
TenantID
value is used for resources that are dedicated to a single customer. For example a customer-specific database or a dedicated compute instance. The costs for these resources can be directly attributed to the corresponding tenant.Shared
value is designated for resources used by multiple customers. These include the control plane, shared database clusters, or messaging queues. Accurately allocating the costs of these shared resources is the most complex part of the process.
Attributing shared resource costs requires more than just tagging. You must instrument your application to capture usage metrics for each tenant. This involves measuring resource consumption at a granular level. Its recommended to start instrumenting from the most significant cost drivers in your architecture. For a shared database, this might involve tracking the number of transactions or amount of data transferred. For a messaging service, you could track the number of messages or data volume sent by each tenant.
The goal of this step is to determine the percentage of a shared resource each tenant has consumed. For example, if Tenant1 used 30% of the shared database and Tenant2 used 20%, these percentages will be used later to allocate the total cost of that resource.
The final step is to combine the total cost of your resources with the usage metrics from your application to generate a comprehensive cost report for each tenant.
The cost of dedicated resources is allocated based on tags. For shared resources, the cost is calculated by multiplying the total cost of the shared resource by the tenant's usage percentage. For instance, if the shared database costs $1,000 and a tenant’s usage is 30%, their allocated cost is $300.
The final report should summarise the costs for each tenant, including a breakdown of dedicated and shared resource expenses. It should provide a clear view of each customer's financial impact on your business.
The right cost allocation model
Choosing the right cost allocation model depends on several factors. Early-stage businesses often prefer a coarse-grained allocation model for its simplicity and lower cost. In contrast, mature businesses may find a fine-grained model more suitable, as it allows them to optimise profit margins and refine pricing strategies. To simplify decision-making, ask yourself the following questions.
Who needs the data, and for what decisions?
For finance and executives, coarse-grained data is usually sufficient, as they focus on the big picture. For product teams, fine-grained cost allocation can be useful to identify expensive features and to help shape pricing strategy.
What is your target pricing model?
For a flat-rate or per-user pricing model, coarse-grained attribution is typically enough, because you’ve already standardised your pricing, so cost attribution doesn’t need extreme precision. For a usage-based pricing model, fine-grained attribution becomes more important, because you’ll likely want to understand your profitability at the usage-unit level.
How diverse are usage patterns for your different tenants?
Coarse-grained cost allocation works well when most tenants consume resources in relatively similar ways. Fine-grained cost allocation is more effective when tenant usage varies significantly across CPU, storage, or network.
What is your tenancy model?
If you use dedicated resources for each tenant, fine-grained allocation is a natural fit. You can simply tag all resources for that tenant. For shared resources, a fine-grained approach is much harder to implement.
In the end, you don’t have to fully commit to one option. Many SaaS companies adopt a hybrid approach: coarse-grained for most costs and fine-grained for expensive resources (such as databases, storage, and compute). Coarse-grained allocation can serve as the default to establish a baseline, and as you scale and observe cost variance across tenants, you can begin selectively implementing fine-grained cost allocation.