Spending
Each product spends only what was allowed, and nothing running is ever stopped for money.
Credit, budget and limit
-
Your product's credit is a monthly ceiling in USD, set by scaledbox when it approves the product and changed only by scaledbox.
-
Its budget, in
scaledbox.toml, is the most you mean to spend, if lower:[budget] usd_month = 15 -
Its limit is the lower of the two.
What is billed
Prices are scaledbox's own, per unit, in USD: GET /v1/prices lists each with its version and since
when. A new price applies from then on. Every hour, the ledger adds a row per resource with its
quantity, the unit's price and that price's version, and the amount, never rewritten (corrections are
new rows); the month's spending is their sum (GET /v1/projects/<product>/ledger).
Billed as reserved, by the hour, whether used or not:
- memory: each service's boxes at its
max_replicas(a range within them costs no more), your Postgres instances; - Postgres disk and bucket size, as declared (
[postgres.main] size = "5Gi",[bucket] size = "10Gi"; 1Gi and 5Gi by default): what is billed is provisioned, your Postgres instance's disk sized to hold every environment's databases, and your tenants' databases' and buckets' sizes (theirdatabaseandbucketlimits); - your tenants' own domains, $1 a month each (
custom_domain_month), 1/730 of it each hour while a tenant has one (Tenants); the names under your tenant domain are free.
Billed as used, within each tenant's month: your tenants' compute, their apps' memory time (a GB
of a box's memory cap awake for an hour, compute_memory_gb_hour) and CPU time (a vCPU for an hour,
compute_cpu_hour), charged each hour once its usage is in (resource compute). Invocations aren't
priced apart: they are paid through the memory and CPU they use. A unit is charged once scaledbox sets
its price (GET /v1/prices); until then it is shown, not charged. Your tenants' other units (rows, KV
units, messages, logs, emails, peak connections, egress: their traffic is billed as traffic, below) are
recorded every minute and shown in the month's spending (unpriced_usage of
GET /v1/projects/<product>/spending), not charged (Tenants); each tenant's month is held
to its own limits.
Billed as used, within a monthly allowance:
| Resource | Allowance a month | At the allowance |
|---|---|---|
| Traffic answered | 100 GB per environment and per tenant | throttled |
| Postgres backups | 10 GB kept per Postgres instance | retention shortened to 7 days |
Bucket requests aren't billed, but have an allowance too: 1,000,000 a month per environment (a
tenant's is its class_a and class_b limits). Past it, the bucket answers 5 requests a second until the
next month (503 SlowDown); S3 clients retry the rest.
Admission: refused before it exists
Anything that would raise spending (a deploy with a higher max_replicas or more memory, a preview, a bigger
database or bucket, a new tenant or a bigger tenant limit, a tenant's own domain) is admitted only if
spent this month + (the hourly rate after it × the hours left) + the remaining allowances ≤ limit.
Otherwise the API refuses it with 402 Payment Required, saying what the change adds a month, by how
much it is over and what to do:
lower it, raise your budget, or ask scaledbox for more credit. Changes that don't raise spending always
pass.
A tenant's month of memory time and CPU (its memory_gb_s and cpu_ms limits) counts as an allowance at
their prices, so a bigger one is admitted the same way.
At the limit
New spending is refused; nothing running is stopped, slept or deleted. A lowered credit only blocks growth. Every reservation is a hard cap (memory limits; a database or bucket at its size turns read-only) and every allowance has an edge, so spending can't grow past what was admitted. scaledbox is alerted at 50, 80 and 100% of a product's limit.
Seeing it
scaledbox spending
shows the month: the limit, what was spent, the projection to the month's end, the hourly rate now and
what the product holds, allowances with what they used. The API has the same
(GET /v1/projects/<product>/spending) and the ledger's rows (GET /v1/projects/<product>/ledger).