I’ve written a worker that depends on pulling some small data from KV in order to route traffic to various backends.
Under load, I’ve seen a small percentage of errors that I believe are due to KV gets failing. Unfortunately I can’t easily recreate this scenario and I don’t have a logging pipeline setup yet, so my ability to see what’s happening is limited.
What I’ve done is something like this:
try {
data = await KVSTORE.get(`${key}`);
}
catch {
return new Response('Server Error: 1001', { status: 520 })
}
And I do see a small number of 520 in my logs. Of course this could be a 520 for a difference reason. I’m thinking about adding a retry, but should this be necessary? I don’t see anything in the docs about doing things like this.
From the doc (https://developers.cloudflare.com/workers/reference/storage/reading-data/):
Return Value
The
.get
method returns a promise which resolves with either the value of your key with the type requested, ornull
if that key is not in the Namespace.
While the limits say “* Unlimited (100k+) reads per second per key” and I don’t believe I’m hitting anything like that.