Scaling
An install is set up at a size band, chosen from the model calls a month you expect: S up to 1 million, M up to 5 million, L up to 20 million, XL above that. The band sets each service’s CPU, memory and starting count. At L and XL, three services scale on CPU. The gateway and the inference proxy, which sit on every model call’s path, already did. From byoc-v0.1.114, ai-service does too. It turns each call’s events into spend rows, and in load tests its fixed pods became a limit as calls rose.
The scaler holds each service near an average of 600 millicores per pod or task. Each of these services is a single Node.js process that tops out a little above one vCPU however large the pod is, so the target is a fixed amount of CPU rather than a share of what the pod is given. At S and M autoscaling is off and the counts are fixed.
On Kubernetes the chart creates a HorizontalPodAutoscaler for each of the three. The autoscaler reads the cluster’s metrics API. AKS ships metrics-server. On EKS, install the metrics-server add-on first, or the autoscaler never moves off its minimum. While an autoscaler scales a service it owns the replica count: an upgrade leaves the count where it is, and you should not
kubectl scale those Deployments. If a GitOps tool applies the chart’s output, tell it to ignore .spec.replicas on the gateway, proxy and ai-service Deployments, or its first sync can drop them to one pod. If you already run your own autoscaler on any of them, remove it or set sizing.autoscale: false, because two autoscalers on one Deployment fight each other. sizing.autoscale: true turns autoscaling on at S and M. The high-availability values file raises ai-service’s minimum to 2.
On AWS the stack adds an ECS target-tracking policy for each of the three, at the same minimums and maximums. While it is on, Application Auto Scaling owns the task count, and a stack update leaves it alone.
The same three services answer their liveness check on a port of their own (4199), from a separate thread. It fails only when the service’s main event loop has stopped turning for 30 seconds, so a pod that is busy, however busy, is not restarted. On Kubernetes, a busy pod that can’t answer its readiness check in time is taken out of rotation until it catches up. Leave the liveness port at its default.
When spend processing falls behind
Services write the spend and audit events they produce to an outbox table in Postgres, and a relay publishes them to Redis streams. The services that record spend and audit entries read those streams as consumer groups. Each stream is capped at about 100,000 entries, which keeps Redis’s memory bounded. In earlier releases, a consumer group that fell a full cap behind (for example while ai-service was down) could lose the oldest entries it hadn’t read yet when Redis trimmed the stream. From byoc-v0.1.114 the spend and audit streams don’t lose them. When a consumer group that is still running falls a full cap behind, the relay stops adding to that stream and keeps the new rows in the Postgres outbox. Other streams keep flowing. When the group catches up, the relay writes the held rows. Nothing is sent twice, so nothing is counted twice. Spend shows up late, not missing. A consumer group is in one of three states.
So ai-service can be down for up to 6 hours without losing spend. Other streams, such as traces and alerts, are trimmed by length as before.
Held rows don’t count toward the inference proxy’s outbox check, which answers SDK observations with 429 when undelivered rows pile up. That check counts only rows the relay could send and hasn’t, such as during a Redis outage, so a hold does not push back on your applications.
What a hold costs in Postgres
We measured about 1.42 KB per held row, including its indexes, on 50,000 synthetic proxy rows. At that size, 6 hours held at 320 calls a second would be about 6.9 million rows, or about 9.1 GiB. That figure is arithmetic from the measured row size, not a measurement of a 6-hour hold. The rows would be in the table anyway, since delivered outbox rows are kept for 30 days. A hold only delays marking them delivered. Still, check the database has that much free space if a hold might run for hours.Settings
These are environment variables the services read. The defaults suit every install we know of. Change them only with the TensorCost team.
On Kubernetes the chart has no value for them. If the TensorCost team asks you to change one, add it to the app secret the services load (
appSecrets.existingSecret). The alert rules below are written for the defaults, so change the matching rule as well. On AWS they are fixed at their defaults.
Metrics
On Kubernetes these are on each service’s metrics port whenmetrics.enabled is on.
Alerts
The chart’s alert rules (metrics.prometheusRule.enabled) include six for this.
Outbox rows are kept for 30 days, so a resend has that long to run.
On AWS, this release has no CloudWatch alarms of their own for these. A hold that lasts longer than 15 minutes still shows up: the stack’s OutboxBacklog alarm watches the oldest undelivered outbox row, held rows included, and Settings › Support reports events that have waited more than 15 minutes. The log lines above go to each service’s CloudWatch log group, where you can add your own metric filters.
Database checks on every boot
These shipped in byoc-v0.1.112.The RLS tripwire
TensorCost keeps each workspace’s data apart in Postgres with row-level security. On top of that, every query a service sends on behalf of a workspace is checked for the shapes SQL injection takes. A hit writes a structured warning,rls.tripwire, at most once a minute per statement shape. It names the service, the route when known, the rule that matched and a hash of the statement with its values blanked out, never the SQL or its values. It also counts the hit in tc_rls_tripwire_total{rule}.
The setting is TC_RLS_TRIPWIRE, and it is log by default: the warning is written and the statement still runs. enforce also refuses the statement, so the request that sent it fails. off checks nothing.
Run
log and read the hits before you set enforce. Let it run against your real traffic for a while, search the services’ logs for rls.tripwire, and send any hit to TensorCost support with its service, route, rule and hash. A hit from normal use is a statement the check doesn’t know yet, and under enforce it would refuse that request. Turn on enforce only once log mode has been quiet.
Legacy database roles are locked
Older releases created database roles namedtensorcost_jobs and tensorcost_ml that no service on a BYOC install signs in as. After every migration pass, each service now takes away their login and password, and their BYPASSRLS attribute. You don’t need to do anything for that part.
Taking BYPASSRLS away needs more privilege than some managed databases give their admin user. Where the install’s database admin isn’t allowed to, as with the RDS master user or the Azure Database for PostgreSQL admin, the roles are left unable to sign in but keep BYPASSRLS, and each boot logs a warning that names the role and gives the statement to run, for example:
rds_superuser where it is allowed) run the statement from the warning once. The warning stops on the next boot. If your database service gives nobody that privilege, the roles stay unable to sign in and the warning repeats on each boot; tell TensorCost support. If a warning instead says a role can still sign in, run the statement it gives, which takes away the login and password.
Background jobs
Settings › Support › Background jobs lists each scheduled job with its last run, and the error when a run failed. On Kubernetes, the chart’s alert rules include TensorCostJobFailing, which fires when a job’s last run has failed for 2 hours, and TensorCostJobStale, which fires when a job has had no successful run in twice its interval plus an hour. Both are warnings, so a restart or a short outage doesn’t page anyone. On AWS, the JobsStale alarm fires when a job hasn’t run in twice its interval plus an hour.Measured capacity
These figures come from load tests on a test cluster on AKS, with five Standard D4s_v4 application nodes and one D4ds_v5 Azure Database for PostgreSQL flexible server, running one workspace with SDK, proxy and gateway traffic mixed 4 : 3 : 1. The per-workspace rate limits were raised for the test, so these rates are above what the size bands’ default limits let through.
For scale, and as arithmetic rather than a measurement: 256 calls a second, sustained, is about 660 million calls in a 30-day month. Band L is sized for up to 20 million.
These are the highest rates measured so far, not a ceiling. If you expect sustained load near them, talk to the TensorCost team about the database size first.