Workers vs Cloud Functions costs?


#1

I was comparing costs between the services and it seems Cloudflare workers is a lot cheaper.

Cloud functions:

Memory: 256MB CPU: 200Mhz
Execution time: 4000ms (Our estimated request time towards third party API)
Bandwidth: 3kb (equals 3 request payloads in our worst use-case)
Invocations: 10 million
Scripts: Unlimited

Cost: 663$

Cloudflare workers:

Memory: 256MB CPU: ?
Execution time: 15 000ms max
Bandwidth: Unlimited
Invocations: 10 million
Scripts: Unlimited (1 per domain)

Cost: 200$

EDIT: Nevermind, Cloud functions actually meassure the WHOLE execution time, not CPU time - so in this case Cloudflare workers offer 15 seconds! I’ve updated the numbers above to reflect this.

Thinking about this even more, Cloud Function containers can take seconds to boot up! This means that the estimated 4000ms above can potentially be several times larger.


#2

Question though: Does internal traffic count? Let’s say i setup two scripts and i make requests between them - does that count as requests too, even between edge-servers? (This is free on Cloud Functions, Amazon and OpenWhisk)


#3

They are different things though, one is a full Node.js environment, the other is a V8 JS Engine…


#4

Both run JS so to those implementing functionality - costs, performance and development time matters.

Cloudflare provides the best performance and the lowest costs, although, development costs might be higher due to not being able to use many node.js specific packages.

But that’s not clear cut either, cloudflares engine implement more modern features than node.js do, like almost the full Web API spec - making it possible to build more efficient apps than using bloated node.js packages (One of the most common packages “request” is 1MB packed!) which can be exchanged by the native fetch API.


#5

You can only have one worker script, unless you are on the Enterprise plan.


#6

You can have as many as you want, but you’ll have to add a new domain for each script.


#7

Yeah, but that becomes a little impractical. As for requests between scripts I would assume almost at 100% certainty that they count towards your billing.


#8

It certainly is impractical for big apps, so is the 1MB script limit. So it’s not for every use-case.

I’m waiting for an official answer, I’m thinking, maybe we can call it like “localhost” or something and it won’t count.


#9

Thanks for the detailed comparison! You do get charged for every execution of your Worker, whether it’s being requested from another Worker or the public internet.

In general the economics of Workers is 3-10x cheaper than other Cloud function providers. It can be even more dramatic when you include all the things they charge you for (like bandwidth) which are included with Cloudflare.


#10

Yeah, I noticed that even 1MB (Basically a single image) of bandwidth per request would raise the above example from 663$ to 1356$. That’s an insane difference compared to Cloudflare Workers! Guess they have to earn their revenue somehow.


#11

Just to help with those landing here from Google. The memory limit for workers are 128MB according to the Resource Limits page.


#12

I believe I’ve seen that 256MB is allocated when on the 200$ plan?

Maybe CF can chip in?


#13

I knew of only the change in CPU time upgrading the plan level…