Is there a way to execute a worker from a DO where the walltime of this worker is not added to the w

Is there a way to execute a worker from a DO where the walltime of this worker is not added to the walltime of the DO?

It might be a bit cheeky, but what I am trying to do:
  • Have a DO take care of administration for my users.
  • Once in a while (via alarms), the DO asks a worker to check in with an external API for an update.
  • This external API can be extremely slow. Think 10+ seconds to come up with an answer. As such, the worker returns a response near-instantly, while via
    ctx.waitUntil
    the external API fetch is finished, and a D1 table is updated.
  • This way the DO isn't blocked on the fetch for very long.
From a cost perspective, paying for 10s of walltime is ofc very expensive (especially as it is just waiting). So the idea of this setup was that the DO would run in short burst, and let the worker do the waiting on the external API.

However, and documentation suggests the same: Cloudflare is being nice (which I appreciate btw) and doesn't charge for the second worker invocation. But also adds the walltime of the second worker to the DO walltime. And I can't find a way for it to stop doing that πŸ˜„

I tried several things:
  • Use service-bindings (works, but walltime is added together)
  • Use service-bindings and set smart placement on the worker (works, but DO now shows both requests in the GB-s graph, suggesting they are both billed under DO pricing)
  • Use direct HTTP (doesn't work, as you can't call a worker on your own account from another worker without a service-binding, it seems)
Any advise or best practice how to deal with DOs and fetches to external APIs that are very slow? πŸ™‚
Was this page helpful?