Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: cloudflare "double" billing? #2

Open
tsdexter opened this issue Oct 1, 2024 · 1 comment
Open

question: cloudflare "double" billing? #2

tsdexter opened this issue Oct 1, 2024 · 1 comment

Comments

@tsdexter
Copy link

tsdexter commented Oct 1, 2024

Thanks for the work on this. It looks good.

Going through the code, just want to confirm, it looks like for (almost) every request to your site you will get billed by cloudflare for both a workers request and a KV read. For stale content, you'll get both a workers request and KV write request billed? Am I thinking about that correctly?

As well, have you been able to determine the amount of CPU time used for successful KV responses? Obviously, for non-KV responses the CPU time will be highly dependent on how long your framework of choice takes to render the page.

Lastly, neither workers nor KV appears to charge for bandwidth, so am I correct that you'd only get billed by the amount of invocations and the amount of storage in KV?

@reegodev
Copy link
Owner

reegodev commented Nov 5, 2024

Hi!
I've created this repo 3 years ago as an experiment, so I'm not really sure it still works.
Regarding your questions:

  • Every read to KV goes through the Cloudflare cache first as implemented in @cloudflare/kv-asset-handler. Even though cache hits are non-deterministic, if your site has a lot of traffic you can be quite sure most of the requests for an asset will hit the cache
  • Workers only bill for non-IO-bound CPU time, that means the time waiting for the KV response is not billed ( I'm not 100% sure but KV.get being async I assume it's going to make some kind of TCP call )
  • Yes bandwidth transfer is always free on Cloudflare for every product

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants