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

Does it make sense to use cloudflare worker kv statestore for r2 uploads #15

Open
rverma-dev opened this issue Jun 9, 2024 · 2 comments

Comments

@rverma-dev
Copy link

The examples only demonstrate usage of cloudflare kv state store for b2. Wondering whether we could get benefitted with using worker KV state store or the default worker cache is sufficient?

@Klowner
Copy link
Owner

Klowner commented Jun 10, 2024

The short answer is no, I would recommend using @tussle/state-memory-ttl with Cloudflare/R2.

I'll happily provide a long answer when I'm at my computer.

@Klowner
Copy link
Owner

Klowner commented Jun 10, 2024

The long answer:

  • Workers KV is described as "low-latency" while R2 offers strong consistency guarantees.
  • @tussle/storage-r2 requires a state provider to operate, but if an upload is absent from the attached state provider, the R2 storage adapter will reconstruct state from R2 on-demand (assuming the upload chunks are in the bucket) and write the rebuilt state back into the attached state service to accelerate subsequent read operations and minimize R2 API calls.

So with that in mind: using a transient in-memory state store with R2 means upload state and data are stored in a single point of truth (good!), and that point of truth has global strong consistency guarantees (also good!).

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