Allocate shared BigQuery reservation costs without inventing query prices
In brief
Charge purchased BigQuery capacity to the teams that requested it. Divide agreed shared costs by measured usage.
- Reconcile allocations to the billing export. Borrowing idle slots can increase usage without increasing the bill.
- Show unused capacity and any unallocated cost separately.
Finance needs a reporting job to finish before the working day starts. Its reservation has a baseline chosen for that workload.
Product runs in another eligible reservation that borrows Finance’s idle capacity. By month end, Product has consumed most of the slot time. Charging it most of the bill is easy to calculate, but that doesn’t explain why the company bought the capacity or who can decide to stop paying for it.
We’d assign the cost of protected capacity to the team that requested it. We’d then divide the remaining shared costs by an agreed consumption measure. Keep a platform or unallocated line for costs without a defensible team owner. Publish usage alongside those amounts so a team can still see expensive demand when another budget funds the capacity.
This policy is for a company that already shares capacity and needs a financial allocation. Whether BigQuery reservations were the right purchase is a separate decision.
Start with the amount the company owes
Define a cost pool for one currency, accounting period, and capacity scope. Record the administration projects, locations, editions, and capacity SKUs it includes. Keep storage, on-demand queries, BI Engine, and separately billed services outside the pool unless the allocation policy names them. A service-level total is too broad for this calculation: capacity is only one of BigQuery’s charging models.
Use the payable cost after discounts, credits, and adjustments. The Cloud Billing export has the cost, credit, currency, and invoice fields needed to keep that scope. Keep the extracted rows and the time you closed the calculation.
Show a later correction as a visible adjustment under the same policy. Last month’s team statement stays as issued.
The billing export also includes an Analysis Slots Attribution line item with slot-hours by consuming project. It’s attribution data with zero cost, and it doesn’t change the invoice. Don’t add those hours to paid capacity usage or treat the line as another charge.
Where commitments or discounts cover several reservations, keep the pool broad enough to include everything they cover. Splitting it into reservation-sized bills may need another allocation rule.
Name that rule in the calculation, because the invoice doesn’t contain the split.
Why slot time and purchased capacity diverge
BigQuery can share idle baseline or committed capacity with other eligible reservations. Borrowing uses capacity that was already available, and the owning reservation can reclaim it. A large amount of borrowed work can arrive without a matching new purchase.
Autoscaling separates allocated capacity from active work. Billing follows the scaled capacity rather than exactly the slot milliseconds consumed by successful jobs. Failed jobs can still cause scaling charges.
Autoscaling currently has a default minimum duration and an optional fluid-scaling mode that changes it. Read the reservation settings before inferring billed duration from a usage chart.
Product can consume most of the compute even when Finance’s deadline caused most of the purchase.
Consumption shows which queries to improve first. The purchase requirement shows who must accept a different service level before capacity can be reduced.
A cost divided by slot-hours can work as an internal allocation rate. It misleads when shown as the price Google charged for each query. Removing that query may free capacity for someone else and leave this month’s commitment bill unchanged. The error runs the other way too: one short burst may add autoscaled capacity whose cost a monthly average rate represents poorly.
Choose the allocation before looking at who benefits
For each purchased-capacity portion, record the workload requirement, the team that accepted the cost, and the next date the decision can change. A morning deadline can justify capacity that sits idle later in the day.
Capacity kept only because nobody has reviewed it needs a named platform owner and a review date. Don’t remove the idle line and leave active users to fund it.
Then choose how to divide the flexible or shared remainder. Slot consumption is a reasonable, reproducible starting point for broad team allocation. Use it as an agreed accounting policy, knowing it can’t show which team caused each autoscaling increment. For a disputed burst, examine the interval and reservation involved before attributing it to the team with the largest monthly total.
Consider a net capacity bill of 12,000 currency units:
- 8,000 covers capacity kept for Finance’s protected reporting requirement.
- 2,000 covers baseline capacity the platform team agreed to fund for general availability.
- 2,000 is the flexible cost pool allocated by observed slot consumption.
Finance accounts for 30% of the eligible measured slot time and Product for 70%. With the ownership policy, Finance receives 8,600, Product 1,400, and the platform budget 2,000. With a pure usage policy, Finance receives 3,600 and Product 8,400. Both add to 12,000.
We’d use the ownership policy if Finance can change the requirement that caused the purchase. It lets Product use otherwise available capacity without inheriting most of a decision it didn’t make. Finance still sees its 30% usage, Product sees its 70%, and the platform team has to explain the capacity it funds.
A pure usage split is defensible when teams have jointly agreed to fund one pool in proportion to consumption and no team has a separately protected entitlement.
Keep the rule stable through the period. Choosing whichever formula makes this month’s most vocal team happy turns a calculation into a monthly negotiation.
Build a denominator you can defend
Start with projects when they have clear team ownership. If several teams submit jobs through one project, use a controlled job label or another verified workload mapping. The JOBS metadata includes labels, reservation identity, edition, and slot time. A job’s submitter email may identify a shared service account rather than the team responsible for its work.
For interval-based allocation, JOBS_TIMELINE gives consumed period_slot_ms per second. Filter it to reservation usage and exclude script parents so their children’s slot work isn’t counted twice. Then sum slot milliseconds across the agreed interval and divide by 3,600,000 for slot-hours of observed work.
Collect every project using the selected capacity. The reservation administration project’s job history misses jobs submitted from other projects.
An organization-level JOBS_TIMELINE view needs organization-level visibility. Without it, collect each project’s view with authorized access. Match the location and edition to the cost pool, and include the job types whose work the pool is meant to fund.
Use fixed time boundaries for the allocation period. If a job crosses them, a timeline-based measure can count only the work inside the period instead of assigning the entire job to its completion date. Keep the mapping that applied then, so reorganizing projects next month doesn’t change who owned last month’s jobs.
Unknown owners stay visible in the denominator and receive an unallocated share. Dropping their rows would increase everyone else’s allocation and make the report look complete.
If no eligible usage was observed, keep the flexible amount unallocated and investigate coverage.
Reconcile money and use the result for a decision
For each team, the statement should show the purchased-capacity amount assigned by ownership, the consumption share of the flexible pool, and any unallocated amount. Show observed slot-hours alongside. Someone should be able to reproduce the result from the saved billing pool, usage extract, ownership mapping, and policy version.
Round at the settlement step.
If allocating currency to minor units leaves a remainder, assign it by a documented deterministic rule. Check that the final amounts sum to the selected payable pool. Don’t round a per-query rate early and expect thousands of rounded allocations to reconcile by accident.
Review cases where the two views disagree. High consumption with little allocated cost may be successful use of spare capacity. A large owned-capacity bill with little consumption may mean intentional protection, obsolete demand, or an oversized purchase.
Reconstructing capacity billing from metadata has limits too: metadata-based estimates can differ through rounding and historical-resource coverage. Take the pool’s total from billing data.
If these amounts won’t change a capacity decision, a service requirement, or a team’s budget, keep the bill in a shared platform budget and report usage for engineering work. We wouldn’t run a monthly allocation process that costs more staff time than the decisions it improves.
More in this domain: Operations
Browse allKeep BigQuery federation from overloading PostgreSQL
Use BigQuery federation for narrow, occasional PostgreSQL reads. Move repeated historical reporting to an analytical copy.
Plan regional recovery for a single-region service
Rehearse a full restore outside the primary region. Consider a warm standby if restoration can't meet the recovery time or data-loss target.
Cloud SQL vs. AlloyDB for PostgreSQL: what earns the migration
Start with Cloud SQL for a modest PostgreSQL application. Test AlloyDB when its read scaling, storage, or columnar engine addresses a measured need.
An alert is not a notification
Send a notification when awareness is enough. Create an operational alert when someone owns a decision.
Why alert feedback should be structured first
Collect a structured response first and leave room for an optional note.
Related patterns
AlloyDB managed connection pooling: when we'd trust it over PgBouncer
Replace PgBouncer with AlloyDB managed pooling when the application fits its pooling mode and operators can still diagnose waits and reconnects.
Managed connection pooling in Cloud SQL: when it helps and when it complicates things
Try Cloud SQL managed pooling when connection bursts exhaust sessions while PostgreSQL still has capacity to do the work.
Reservations for workload isolation: the minimal setup
Create a BigQuery reservation when one workload repeatedly delays another.
When cold history should stay in BigQuery
Keep cold history in BigQuery when retrieval costs would outweigh the storage savings.