251 points · by jgrahamc · 8y ago · 100 comments
Seriously, if you're new to that domain go read:
https://aphyr.com/posts/333-serializability-linearizability-...
One great example of why this would matter to me - could workers ever institute a coordinated rate limiting function using this KV store?
By combining those with KV to do global coordination on a more course time scale, I think you could.
https://en.wikipedia.org/wiki/Compare-and-swap
It might be straightforward to do this with an ETag like Firebase:
https://firebase.googleblog.com/2017/07/introducing-conditio...
Not sure what this would require on their backend though.
(This logic is not quite in production yet but should be within a week or two.)
It can work for simple apps but there's a long way to go before any serious enterprise system will be hosted entirely on a FaaS system like Workers.
You're right for some use cases though.
At the point that CF replaces the origin, it is the origin.
The confusion in your query is the idea that "origin" is a rigid, fixed concept rather than flexible.
Would also be great if CF could do websocket / sse fanout at the edges - if I have a couple million websockets connected on ws.cf.com/key1 and I update the value, would be great if the new value could be broadcast. That would help with a lot of media / real-time / sports games, apps and websites.
The more specific cases include opening ticket sales for movies in India - for some big movies tickets are sold out really quickly, so there'll be hundreds or thousands of people with browsers / phones open on a seat layout and they all need to see which seats are being sold in real-time.
Then there's broadcasting stock market movements and tips to thousands of traders in real-time.
The only existing solutions that seem really scalable are fanout.io - others like pusher.com and pubnub.com have pricing that's not conducive to serving a large number of simultaneous users / broadcasting. Fanout.io gets this right, but would be nice to have cheaper alternatives / make it a commodity.
Given that the CF nodes do support websockets, I assume they terminate and re-create new connections to origins as well - so the nodes are capable of holding a large number of websockets open, right? Can Workers intercept websockets / stream data into them? And given that the KV store is capable of propagating new values to all the nodes, there could be a way expose incoming change notifications on keys, which would handle this use case. Could also implement as continuous addition of new timestamps keys, prefixed with a topic.
If you can accept up to 10s of latency, I agree that KV could solve the 'pushing events' problem for you. (A tuple store is semantically equivalent to message passing, and it will get easier when we support range queries).
Hi! Fanout founder here. I’m glad you like our way of doing things. If you need better pricing for high volume we are always willing to discuss.
I’m not sure you’d want to maintain a WebSocket inside of a CF worker. At least I can’t see that helping with cost. Execution time limits would get you too. IMO connection management belongs as a separate layer in front of the worker, so workers are only woken when things happen.
And on that note, of course you can use Fanout together with Cloudflare Workers today. At the moment this requires making raw API calls but we plan to update our server libs for CF compatibility soon.
> There's no truth in the rumour that a KV store is a @KentonVarda store. Nor that it maps kentons to vardas.
If you’re truly replicating to every PoP that’s quite a fan-out and I can see why you’re limited to 1 write per second per key!
Can you create data spaces/keys for ones that are read-write per-user and others that are read-only for a given user?
Aside, it seems like this could be really interesting combined to make an entire API with static delivery from S3 or Azure Blobs, with a backend on a cloud hosted database. With a lot of flexibility in between.
When you say overhead limit, are you talking about latency? Our goal is to keep reads on the order of 5ms in the 90th percentile.
There's a (K,V) pair somewhere, but in order to get V, you need K, which you've lost.
You could also store carts by session id until they're logged in, and then store the carts by account id when they are.
No big dataset needed, just some regex and if/then statements. If you still want a library then you can try https://github.com/faisalman/ua-parser-js
Our hope is that anyone could create such an API, not just Cloudflare. Just like we are building storage on top of workers, we hope to eliminate the distinction between what is possible for a Cloudflare employee and what is possible for any of our customers.
I think you might be overestimating that. Bundling the aforementioned https://github.com/faisalman/ua-parser-js wouldn't be significant - maybe hundreds of KB as a script (distinct from memory!) - at most.
Like, "show me all keys that match xyz∗ in this namespace"
I've considered similar for shard keys in terms of proximity related information.
$5/month for
- 1 GB of KV storage and up to 10 million KV reads
- 10 million requests
After that it's $0.50/month - per million requests
- per GB of storage
- per million KV reads
I think that's well within startup money. I mean, if a company has to give out credits perhaps it's just too expensive :-)