CrabTalk
Blog

Do serverless functions bill memory while they wait on an API?

Lambda, Durable Objects and Vercel bill memory while a call waits on a fetch. What each platform charges for the wait, and a tool measured holding 2 MB of 23.

CrabTalk Team

An agent tool spends most of its life waiting. It sends a request to an upstream API or a model, and then nothing happens on its CPU for hundreds of milliseconds or several seconds. Most serverless platforms keep billing the function's memory through that wait, at its full allocation. This post shows what each platform bills while a call awaits a fetch, measures how much memory a real tool actually holds during one, and explains how CrabTalk now bills a waiting call for the memory it is using rather than the memory it reserved.

What a waiting call is billed for

Platform Memory billed while a call waits on a fetch Source
AWS Lambda The configured memory, at least 128 MB, for the whole duration: "from the time your code begins executing until it returns" Lambda pricing
Cloudflare Durable Objects 128 MB for wall-clock time while the object is active; "pending I/O operations keep an object in memory" and it "incurs duration charges during that time" Durable Objects pricing
Vercel Functions (Fluid compute) Provisioned memory, which "continues billing while handling requests, even during I/O operations"; CPU billing pauses Vercel usage and pricing
Cloudflare Workers (Standard) Nothing: Workers bill CPU time, and "waiting on network requests ... does not count toward CPU time" Workers pricing, limits
CrabTalk The memory the call has grown to, not its budget Budgets

Pages read November 29, 2026. Vercel shares one instance among concurrent requests, so its memory line is split across whatever else that instance is serving at the time.

Workers are the exception because they bill no memory at all. The others multiply an allocation by wall-clock time, and for an agent tool most of that time is waiting.

How much memory a waiting call actually holds

We measured CrabTalk's SEO service, whose check tool fetches a page and reports its technical SEO issues. It declares a memory budget of 23 MB. We ran it with crab budget bench against four live sites, three times each, with real HTTP requests, on November 29, 2026:

Site Memory the call grew to Wall time CPU time
example.com 1.75 MB 246–792 ms 2–36 ms
rust-lang.org 1.94 MB 490–1,211 ms 5–6 ms
en.wikipedia.org (answered 403) 1.75 MB 256–1,607 ms 1–2 ms
crabtalk.ai 3.38 MB 529–1,221 ms 10–18 ms

CPU was at most 5% of any call's wall time and usually under 2%; the rest was the fetch. Through all of it the call held at most 3.4 MB, a seventh of its 23 MB budget, and usually less than a tenth.

The budget is a ceiling sized for the largest page the tool supports. The typical call needs a small fraction of it, and almost all of the call is a wait.

What the wait costs

The memory line alone for a million calls that each wait 3 seconds on an upstream API:

Platform Memory billed Memory cost per million calls
Lambda (x86) 128 MB $6.25
Durable Objects 128 MB $4.69
CrabTalk, billed at the 23 MB budget 23 MB $0.69
CrabTalk, billed at the memory in use 2 MB $0.06
Workers none $0.00

Lambda at $0.0000166667 per GB-second and Durable Objects at $12.50 per million GB-seconds, as read November 29, 2026; CrabTalk at its list rate of $10.24 per million GB-seconds. Requests, CPU and rows are charged on top on every platform; the methodology has the full model and Lambda and Durable Objects bill 128 MB of memory covers the allocation floor.

Shrinking a call while it waits

CrabTalk runs each service as WebAssembly. A call reserves its memory budget from the host when it starts, and the host charges that reservation for as long as it is held. Until now, a call held its full budget for its whole life, waits included.

A call that waits on a fetch, or on a call to another service, is suspended inside the host call. A suspended guest cannot grow its memory, so everything between what it has grown to and its budget is reserved for nothing. The host now does three things around every such wait:

  1. Before it awaits the response, it lowers the call's reservation to the memory the guest has grown to, and gives the rest back to the host's memory pool for other calls.
  2. When the response arrives, it takes the full budget back before the guest runs again. If the pool is full at that moment, the guest waits for room, within its deadline.
  3. It bills each reservation for exactly as long as it was set.

Nothing changes for the code. The guest cannot observe the shrink, so it applies to every call, and there is no setting for it. The mechanism is in the open-source Crab runtime.

What it does not do

  • The wait is not free. The memory a call has grown to is still billed while it waits. It is a small number, but it is not zero.
  • Workers still bill less for the wait. They charge no memory at all. What they do not have is state of their own: a Worker that needs storage uses a Durable Object, which bills 128 MB for the whole wait. A CrabTalk service has its own SQLite database, and its waiting calls hold a few megabytes.
  • Only waits on the network shrink. Fetches and calls to other services lower the reservation; host calls that answer at once do not.
  • A call that writes before it waits still holds its database's writer for the wait. Fetching before the first write avoids it.

If you build on CrabTalk

  • Measure what your tools grow to with crab budget bench before you set a budget. The budgets guide explains each limit.
  • Size the budget for the largest input you support. Waiting calls are billed for what they use, so a generous ceiling no longer costs you while a call waits on an API.