From 3e83d3a762d5092045b2eba6755e6d4abe3adf48 Mon Sep 17 00:00:00 2001 From: Blake Bauman Date: Tue, 25 Aug 2026 18:56:47 -0700 Subject: [PATCH] perf(containers): 15m of idle, not an hour and not two 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, so with the uptime monitor undeployed this timeout is the only thing bounding what an idle container costs. All three drop to 15m. demo 1h -> 15m enterprise 1h -> 15m demo-tasks 2h -> 15m demo-tasks had the longest tail and the least reason for it. The 2h predates the teardown and carries no stated rationale; the board is ephemeral by design, demo jobs run for seconds, and the gateway forwards every tasks call — so the upstream stays awake exactly as long as anyone is actually using it, and there is no state here worth paying to keep warm. A poll that does land on a cold start gets the 503-and-retry the Worker already returns. The cost is a ~1.7s cold start for the first visitor after a quiet quarter hour, measured on lite in #46. That is a fair trade for a demo people arrive at one at a time rather than in a steady stream, and the enterprise gateway has more reason still: it sits behind a sign-in, so it is idle more of the time than the demo is. Verified after deploy: all three healthy, tools/list returns 8 tools across three namespaces with no partialFailure, and jobs__start_job still mints through the affinity pin. Co-Authored-By: Claude Opus 5 (1M context) --- apps/demo-tasks/src/index.ts | 7 ++++++- apps/demo/src/index.ts | 14 ++++++++------ apps/enterprise/src/index.ts | 8 ++++---- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/apps/demo-tasks/src/index.ts b/apps/demo-tasks/src/index.ts index cac943f..1c71362 100644 --- a/apps/demo-tasks/src/index.ts +++ b/apps/demo-tasks/src/index.ts @@ -9,7 +9,12 @@ import { Container, getContainer } from '@cloudflare/containers'; export class TasksBoard extends Container { defaultPort = 8080; - sleepAfter = '2h'; + // Matched to the gateways rather than left at the 2h it had. The board is + // ephemeral by design and demo jobs run for seconds, so there is no state + // here worth paying to keep warm — and the gateway forwards every tasks + // call, which keeps this awake for exactly as long as anyone is using it. + // A poll that does land on a cold start gets the 503-and-retry below. + sleepAfter = '15m'; enableInternet = false; // it dials nothing; it only answers } diff --git a/apps/demo/src/index.ts b/apps/demo/src/index.ts index 65c7bca..a83beac 100644 --- a/apps/demo/src/index.ts +++ b/apps/demo/src/index.ts @@ -31,12 +31,14 @@ const FOLD_CONFIG = { export class FoldDemo extends Container { defaultPort = 8080; - // 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'; + // The only thing bounding what this 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 every idle + // minute after a visitor leaves is provisioned memory and disk on the bill. + // 15m buys the tail back for a ~1.7s cold start on the next visitor, which + // is a fair trade for a demo people arrive at one at a time rather than in + // a steady stream. + sleepAfter = '15m'; enableInternet = true; // fold dials the public upstreams envVars = { FOLD_CONFIG: JSON.stringify(FOLD_CONFIG) }; } diff --git a/apps/enterprise/src/index.ts b/apps/enterprise/src/index.ts index 82afbd1..79dd117 100644 --- a/apps/enterprise/src/index.ts +++ b/apps/enterprise/src/index.ts @@ -199,10 +199,10 @@ const FOLD_CONFIG = { export class FoldEnterprise extends Container { defaultPort = 8080; - // 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'; + // The same billing lever as the demo's, on the same 15m, and with more + // reason to be short: this gateway is behind a sign-in, so it sits idle + // more of the time than the demo does. + sleepAfter = '15m'; enableInternet = true; // fold dials the public upstreams and the issuer's JWKS envVars = { FOLD_CONFIG: JSON.stringify(FOLD_CONFIG) }; }