Workers KV API is super slow compared to bindings

Measurements made in browser

Workers KV API calls from a worker :

  • Put : 1.25 seconds
  • Get : 1.14 seconds
  • Del : 1.28 seconds

Workers KV Bindings calls from a worker :

  • Put : 53 milliseconds
  • Get : 28 milliseconds
  • Del : 14 milliseconds

Conclusion

  • Binding performance is OK
  • API calls should be avoided
1 Like

This is known and it’s due to how those work. The API goes back to the central server, the bindings are cached locally in the same POP where the worker is running.

2 Likes

So you’re saying, with bindings, the write is made on the edge store, then replicated later on the central store ?

.put() .del() you could use event.waitUntil(await KV.put(...))

1 Like

Yes, it could accelerate even more the thing !

That’s why you can do an immediate KW write and read in same worker request and the read will still be reliably instant.

2 Likes

Exactly. Later meaning a max of 60s (usually much much lower, basically API time), being an eventually consistent KV store.

1 Like