From a8e6015c350b1358709136d3fbbaa2c62639f7de Mon Sep 17 00:00:00 2001 From: Blake Bauman Date: Tue, 25 Aug 2026 17:20:31 -0700 Subject: [PATCH] perf(demo,enterprise,containers): lite is the floor, and it is enough MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Memory and disk bill on what is *provisioned*, for every awake second; only CPU bills on what is used. An oversized instance therefore costs full price to sit idle, which is most of what a gateway does. Both gateways were `basic` — 1 GiB and 4 GB — against a real footprint a fraction of that. Measured under exactly lite's limits (--memory 256m --cpus 0.0625), on these configs rather than a sample one: demo boots 1.65s, idles 9.7 MiB, peaks 12.1 MiB across five concurrent federated sessions — 4.7% of the 256 MiB cap enterprise boots 1.75s, idles 11.0 MiB with auth, tenants, policy and audit configured demo-tasks idles 42.3 MiB, already lite, unchanged So `lite` is not a squeeze, it is roughly 20x headroom. It is also the floor: a custom instance type requires a minimum of 1 vCPU and 3 GiB per vCPU, which makes the smallest configurable one *larger* than `basic`. Under 1 vCPU the choice is lite or basic and nothing else. And because CPU bills on utilization, the two cost the same to compute with — the 1/16 vCPU is a ceiling on bursts, not a saving. That ceiling is what to watch if fan-out slows with many upstreams; going back is one line. Verified after deploy: both gateways healthy, tools/list returns all 8 tools across three namespaces with no partialFailure, and jobs__start_job still mints through the affinity pin. Images were already minimal and are untouched — the gateways are the unmodified distroless release (47.2 MB), which is the claim the demo page makes, and demo-tasks is already multi-stage distroless static at 4.08 MB. Also corrects a comment that had gone false: sleepAfter was documented as a backstop because the uptime monitor pinged every 5 minutes and kept these warm. That monitor is undeployed, so the timeout alone now decides how long an idle container stays on the bill. Left at 1h; shortening it is the other half of this bill and a separate call. Co-Authored-By: Claude Opus 5 (1M context) --- apps/demo/src/index.ts | 7 +++++-- apps/demo/wrangler.jsonc | 15 ++++++++++++++- apps/enterprise/src/index.ts | 5 +++-- apps/enterprise/wrangler.jsonc | 15 ++++++++++++++- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/apps/demo/src/index.ts b/apps/demo/src/index.ts index 2e9b8a2..65c7bca 100644 --- a/apps/demo/src/index.ts +++ b/apps/demo/src/index.ts @@ -31,8 +31,11 @@ const FOLD_CONFIG = { export class FoldDemo extends Container { defaultPort = 8080; - // The uptime monitor pings every 5 minutes, so in practice this never - // sleeps; the timeout is the backstop if monitoring stops. + // This is now the only thing bounding what the container costs. It used to + // be a backstop — the uptime monitor pinged every 5 minutes, so in practice + // the container never slept — but that monitor is undeployed, so an idle + // hour after one visitor is an hour of provisioned memory and disk on the + // bill. Shorten it to trade a ~1.7s cold start for that tail. sleepAfter = '1h'; enableInternet = true; // fold dials the public upstreams envVars = { FOLD_CONFIG: JSON.stringify(FOLD_CONFIG) }; diff --git a/apps/demo/wrangler.jsonc b/apps/demo/wrangler.jsonc index 6f9e592..94a8b4f 100644 --- a/apps/demo/wrangler.jsonc +++ b/apps/demo/wrangler.jsonc @@ -24,7 +24,20 @@ { "class_name": "FoldDemo", "image": "./Dockerfile", - "instance_type": "basic", + // Memory and disk are billed on what is *provisioned*, for every awake + // second; only CPU is billed on what is used. An oversized instance + // therefore costs full price to sit idle, which is most of what a + // gateway does. `lite` is 256 MiB / 2 GB / (1/16) vCPU, and that is + // measurably enough: under exactly those limits, fold v1.13.0 on this + // config boots in 1.65s and idles at 9.7 MiB, peaking at 12.1 MiB across five concurrent federated sessions. There is + // no dial between this and `basic` and nothing below it — a custom + // instance type needs a minimum of 1 vCPU and 3 GiB per vCPU, so the + // smallest one that can be configured is larger than `basic`. Because + // CPU bills on utilization, `lite` and `basic` cost the same to compute + // with; the 1/16 vCPU is a ceiling on bursts, not a saving. That ceiling + // is what to watch if fan-out gets slow with many upstreams, and going + // back to `basic` is this one line. + "instance_type": "lite", "max_instances": 1 } ], diff --git a/apps/enterprise/src/index.ts b/apps/enterprise/src/index.ts index 69d3ecc..82afbd1 100644 --- a/apps/enterprise/src/index.ts +++ b/apps/enterprise/src/index.ts @@ -199,8 +199,9 @@ const FOLD_CONFIG = { export class FoldEnterprise extends Container { defaultPort = 8080; - // The uptime monitor keeps this warm the same way it does the demo; the - // timeout is the backstop if monitoring stops. + // The same billing lever as the demo's, and the same caveat: the uptime + // monitor that used to keep this warm is undeployed, so this timeout alone + // decides how long an idle container stays on the bill. sleepAfter = '1h'; enableInternet = true; // fold dials the public upstreams and the issuer's JWKS envVars = { FOLD_CONFIG: JSON.stringify(FOLD_CONFIG) }; diff --git a/apps/enterprise/wrangler.jsonc b/apps/enterprise/wrangler.jsonc index dc070c4..e0868cd 100644 --- a/apps/enterprise/wrangler.jsonc +++ b/apps/enterprise/wrangler.jsonc @@ -28,7 +28,20 @@ { "class_name": "FoldEnterprise", "image": "./Dockerfile", - "instance_type": "basic", + // Memory and disk are billed on what is *provisioned*, for every awake + // second; only CPU is billed on what is used. An oversized instance + // therefore costs full price to sit idle, which is most of what a + // gateway does. `lite` is 256 MiB / 2 GB / (1/16) vCPU, and that is + // measurably enough: under exactly those limits, fold v1.13.0 on this gateway's larger + // config boots in 1.75s and idles at 11.0 MiB, under 5% of the cap. There is + // no dial between this and `basic` and nothing below it — a custom + // instance type needs a minimum of 1 vCPU and 3 GiB per vCPU, so the + // smallest one that can be configured is larger than `basic`. Because + // CPU bills on utilization, `lite` and `basic` cost the same to compute + // with; the 1/16 vCPU is a ceiling on bursts, not a saving. That ceiling + // is what to watch if fan-out gets slow with many upstreams, and going + // back to `basic` is this one line. + "instance_type": "lite", "max_instances": 1 } ],