Which Cloudflare Container Timeout Costs Less on Replay?
Replay timestamp gaps for one Cloudflare Container instance at two sleep timeouts. Compare CPU, memory, and disk charges alongside cold-start counts and added startup delay.
Find the gaps that change the bill
Group the trace by container instance before making a timeout decision. For sequential work on one instance, a gap below the timeout incurs memory and disk for the entire gap. A gap above the timeout incurs those allocations up to sleep, then brings another startup when work returns. The Cloudflare pricing excerpt meters CPU by active use and lists monthly included usage separately for each resource. That means the same change can reduce billable memory while CPU remains inside its allowance, or add billable startup CPU after the allowance is used. For a basic instance, 50 additional running hours consume 50 GiB-hours and 200 GB-hours before any CPU is counted. Evaluate each meter against the allowance left on the account. Aggregating two instances into one timeline can erase simultaneous idle time and make both timeout choices look artificially cheap.
Pricing · Cloudflare Containers docsVerify the predicted cold starts with one trace
Use the same image and instance size for both timeout trials. The lifecycle documentation describes a Worker routing through a Durable Object to a process on a container port, which gives you a place to record the outer request time separately from application readiness. Send two sequential requests with a gap between the proposed thresholds, then repeat with a gap longer than both. Give the process a boot marker and log that marker, the request ID, and time to first response. The middle gap should produce an extra boot under the shorter timeout in the simple replay model. If both trials show the same boot behavior, inspect routing and lifecycle events before trusting the estimate. Compare cold startup time with your actual request deadline, and track initialization failures separately because repeating requests after a failed start adds costs the replay does not include.
Lifecycle of a Container · Cloudflare Containers docsBuild the estimate from three meters
Start with the Cloudflare instance type and the remaining allowance on your Workers Paid account. The documented plan is $5 USD per month and includes 375 active vCPU-minutes, 25 GiB-hours of memory, and 200 GB-hours of disk. The corresponding overage rates are $0.000020 per active vCPU-second, $0.0000025 per allocated GiB-second, and $0.00000007 per allocated GB-second while running.
Sum active CPU time across instances. For memory and disk, multiply each instance's allocation by its running time and sum the results. Subtract the remaining allowance once per meter and price only the positive remainder. Include the plan fee once in the account budget. If the account already pays it, track incremental overages separately so the estimate answers what adding this agent will cost.
Pricing · Cloudflare Containers docsCalculate a month with long model waits
For an illustrative month, assume one standard-2 instance runs for 30 aggregate hours and averages 10% utilization of its single vCPU. It has 6 GiB of memory and 12 GB of disk. Assume the full monthly allowances are unused at the start, and the 30 hours include startup, model waits, and time before sleep.
The job uses 3 active vCPU-hours, within the 6.25-hour allowance. Memory totals 180 GiB-hours, leaving 155 billable at $0.009 per GiB-hour. Disk totals 360 GB-hours, leaving 160 billable at $0.000252 per GB-hour. That is about $1.44 in container overages, or $6.44 with the plan fee. Keep egress, Workers and Durable Objects usage, and model calls in separate rows when reconciling the account bill.
Pricing · Cloudflare Containers docsFind the shortest timeout that works
Cloudflare documents setInactivityTimeout() for stopping the container after the Durable Object becomes inactive. Try two timeout settings with the same request trace, including the typical gap between jobs and the longest gap inside one job. Record when work finishes, when the instance stops, and how long the next request takes to produce a usable result. Include restarts during realistic model waits in the pilot.
Keep the shorter timeout if it cuts allocated resource-hours and the next request still meets your latency target with the correct state. If a gap in requests stops a container while work is pending, test a longer timeout or save enough progress to resume cleanly. Compare completed jobs and retry counts alongside runtime so premature shutdowns show up in the decision.
Lifecycle of a Container · Cloudflare Containers docs