Does sleeping/delaying count as CPU time?
For the sake of billing and timeout limits does "sleeping" or doing something like
await new Promise(r => setTimeout(r, 60000));
count as CPU time. Like would a worker that uses this code be billed for 60000 ms of execution? If not is there a limit to how long we can sleep to keep a worker going? I have an API that needs to be polled and I want to know if workers can be used for it.2 Replies
It does not count as CPU Time. There isn't an imposed limit, though after 30 seconds there is a slightly higher chance of your Worker being evicted
So would it be better to have a flow like:
http request to store request id in Cloudflare queues -> queue triggers worker which polls api using request id by sleeping on again off again for 10 seconds at a time
Would that make sure it wouldn't be killed for at least 15 mins?
Most polling will be done in under 1 minute but some can take 5min+ so I want to be sure