How it is calculated 10ms CPU time for free tier
I deployed for workers quiet trivial sveltekit app - retrives data from d1 and sends to the user. I noticed that my worker is exceeding free tier of CPU usage by a lot, but is seems that app is still working. Multiple requests are under 10ms and multiple over 100ms. Will my account be locked-out ? What are rules for killking app which exceeds free plan. Is my app exeed this plan ? Thanks

6 Replies
?cpu-time-overage
From the Workers lead engineer on why you can sometimes use more CPU time than your limit (https://canary.discord.com/channels/595317990191398933/1204401951026974780/1204805369658867752):
Each isolate has a "rollover bank" of CPU time. If you use less than your limit on one request, the leftover time is added to the bank. If you use more than your limit on another request, time is taken out of the bank. Only when the bank reaches zero do you actually get an error. Additionally, the bank does not start out empty. When an isolate first starts up, its bank is initialized with some extra time. This is meant to make up for the fact that the first few requests are likely to run slower as the isolate "warms up" (e.g. JIT-compiling code). Actually, we probably give isolates too much initial time. There was a bug some years ago where we gave too much initial time by accident, and then it was hard to fix the bug without breaking people who came to rely on it. We kind of just said, ok whatever, and left it. Because of the initial time, if your worker commonly executes only a small number of requests per isolate, it is indeed possible to exceed the limit regularly. But if you get enough traffic that individual isolates are commonly handling many requests, you'll start to see errors.
TLDR: You don't have enough requests to trigger it. I'm surprised though if it's just querying d1, even ~20ms seems a bit excessive, not too far over though
so it seems that even 5$ worker won't be able to handle sveltekit app for longer run

right?
The max cpu time for Workers Paid ($5) is 5 minutes (defaults to 30 seconds)
cpu time is left col there iirc