I'm debating on just using D1 with a table of key-value pairs, but I was told the latency for KV is significantly less than D1 for repeat lookups.
I'm wanting to do a lookup as a part of every request, so the answer is important here, but I haven't been able to find any data.
How long does it take to load a value from KV? And how long does it take to load a value from a D1 table?
k
kian
01/14/2024, 2:20 AM
I'd recommend looking at rather than having performance as the only factor, they're pretty different solutions.
kian
01/14/2024, 2:21 AM
KV is eventually consistent, with two central stores, and caches at the edge on read.
kian
01/14/2024, 2:21 AM
D1 is built on Durable Objects so it has 1 central store, with no read replicas/caching (currently).
c
Charles Stover
01/14/2024, 7:30 AM
I know the other differences, and none are particularly relevant to my use case. The biggest factor right now is cost, and D1 is a fraction of the cost of KV. Since I can't find a metric on latency, it really does boil down to how much am I paying for how much improved latency.
At edge sounds like KV would be fastest, but I'd really like to know the SLAs or data for the latencies. 🤔
k
kian
01/14/2024, 7:39 AM
I don't think any of them have any SLAs for latencies.
kian
01/14/2024, 7:39 AM
It all depends where you're running your Worker, and where your DO/D1/R2 instance is.
kian
01/14/2024, 7:39 AM
DO/D1/R2 instance in APAC accessed from APAC is faster than KV cold reads, since KV doesn't have a central store in APAC.
kian
01/14/2024, 7:39 AM
Caching is something you can do yourself with all of them using the Cache API