i read somewhere that withing 500ms all KV will be updated (consistent) across all nodes.
then i read somewhere about a 30s data propagation too… not sure what that is for
so if i want true consistency across my app, can i make it delay “0.5s” for each processing? will that make it truly consistent across all nodes?
You should expect a minimum of 30s before it’s updates globally.
this is terrible.
kv update globally at 30s is very very long.
anyways to force the node at one single datacenter? that should make it locally at 0.5s if not mistaken or sooner.
e.g. something.something.workers.dev <- pls use only datacenter nearest to london location
actually i need it to be closest to the primary datastore location, i think that’s in US
It’s a distributed data-store which don’t support ACID writes, if you need that, try FaunaDB.
i understand. but i just need it at 1s or below. coz 30s is really too long. any other solutions that the one i suggested? any ways to force it to go only to the nearest data center?
else would it help if i have a US server that communicates with cloudflare workers? that should make it local right? and within 0.5s
i will write the US local server as a proxy to cloudflare workers
That’s just how the current KV works, last write wins.
There’s no way around it unless they add sync, which no one know if they will ever add.
Also keep in mind that you can only write to the same key 1 time per second.
i think i will write the US local server as a proxy to cloudflare workers then. that should help a lot if not solve this issue. i think the local server will always do 0.5s max if not mistaken.
i’ve gotten consistently 10ms response of updates locally on KV store
You can’t force cloudflare to write to specific KV location, every datacenter they have is a KV store.
Don’t waste time on hacks that won’t work, just go with a database designed to solve your problem.
cloudflare serve the closest origin so the KV used on cloudflare workers will always be updated on the closest node first then propagate globally. i just need something that’s below 0.5s update will do from 1 location.
user -> US server -> cloudflare workers
this should get me consistent 0.5s updated KV values.
There’s no guarantees for which datacenter or worker instance the network will choose, you can get 10 different ones even when connecting from the same location.
KV = 60s
Documentation says KV takes up to 60 seconds to be globally consistent.
Changes may take up to 60 seconds to propagate
Cloud Storage = 0s
If you need a global strongly consistent store you probably want to look into Google Cloud Storage, which uses bits of Google Spanner since 2018 :
Cloud Storage now provides strong consistency
…With one big drawback: Google Cloud is unaccessible from China.
Edge caches : 10s
Not tested, but I was asking myself the same question:
If you need to stick with KV Storage because China, you might try to reduce the consistency lag to 10 seconds.
When you write in KV, use CloudFlare API to cache the data in all your CloudFlare Edge CDN, so they all will be warmed, and consistency will be achieved in 10s. Just like a regular deployment.
Check the source code of wrangler to see how a deployment works.
I’ve been dealing a lot with China market and servers and in todays political climate - I’d not consider any US-based cloud service for building anything serious. I’d just get servers on Ali Cloud, there’s not many reliable alternatives.