3 ms·
Awesome! I have some questions about the way usage works. I'm wondering if there's a point where efficient, short lived executions are more cost effective as
by ryan29 5y ago
Awesome! I have some questions about the way usage works. I'm wondering if there's a point where efficient, short lived executions are more cost effective as Unbound rather than the bundled Workers now. The docs [1] say:
> Cloudflare will bill for duration charges based on the higher of your wall time or CPU time, with a multiple applied to the CPU time to account for the processing power allotted to your script.
Does anyone know how the CPU time is calculated? What's the "multiple"?
Are there any minimums in terms of execution time? I remember when Workers Unbound was announced I didn't see any mention of minimums anywhere, but other provides have them. For example, Azure [2]:
> The minimum execution time and memory for a single function execution is 100 ms and 128 mb respectively.
I remember thinking the examples in the original announcement assumed no minimums. Even if there's a 100ms minimum, are short lived executions that don't do any waiting on I/O cheaper as Unbound Workers now?
# Bundled Cost
$0.50 / 1000000 = 0.0000005 per execution
# Unbound Per GB-s Cost
$0.15 / 1000000 = $0.00000015 fixed cost per execution
$12.50 / 1000000GB-s = $0.0000125 per GB-s (duration cost)
# 100ms Unbound Cost
.1s * .125GB = 0.0125 GB-s per execution
$0.00000015 fixed cost
$0.0000125 per GB-s * 0.0125 GB-s = $0.00000015625 duration cost
$0.00000015 fixed + $0.00000015625 duration = $0.00000030625 total cost
Assuming I calculated that right, it's $0.30 per million for 100ms of execution vs $0.50 per million for a normal Worker. There's wall time vs CPU time, but that's a pretty huge discount for short lived executions, right? Am I way off on something? It seems too good to be true. Lol.
1. https://developers.cloudflare.com/workers/platform/pricing#workers https://developers.cloudflare.com/workers/platform/pricing#w...
2. https://azure.microsoft.com/en-ca/pricing/details/functions/ https://azure.microsoft.com/en-ca/pricing/details/functions/
- kabircf 5y agoWe don't have any 100ms minimums we enforce. We'll charge you on the overall use for the whole month, less any included usage for each model. For some use cases, Bundled makes sense, for others, Unbound makes sense. Again, flexible + affordable is what we're after as we mention in that blog post!
- vlovich123 5y agoThe included amounts in your monthly fee need to be priced in to get an appropriate estimate. I would compute your monthly cost for a certain number of requests rather than trying to multiple a per request number because none of the slopes intercept at 0. At 1 million requests per month, you'll likely be paying $5 on either plan since that's below the baked-in thresholds. I wouldn't really compare the pricing because they're different use cases. * Bundled workers can't do 100ms of compute per request. They're limited to a max of 50ms. * Unbound scripts can use as much or as little compute as you want per request up to a maximum wall time of 30s. * Cron triggers can use up to 15 minutes of wall time per invocation (but can't handle requests). If you can do all I/O & CPU within 50ms, then unbundled might theoretically be cheaper still but that's just on my coarse napkin math. It's hard to correctly model how many Workers you'll end up needing during the month which provides large error bars (e.g if you get 100 requests per second across the globe, the cost will be very different than if you got 100 rps from just 1 machine for the month). The option to pick is the one that satisfies the shape of the problem you are using. Predicting the price you'll end up paying is a bit hard to estimate correctly vs just seeing what your bill ends up being.