Unpredictable latency spikes for Workers, R2 and KV
I'm currently looking at a request to a Worker which had a TTFB of 693ms measured on my side. On the worker side, the time is measured as 492ms, the majority of which is a same-region R2 request. It's a network overhead of almost 200ms (to not say anything about almost half a second to just get the metadata of a stored object)!
(It seems that I was randomly reassigned to a different colo, to which I have a very high RTT. https://speed.cloudflare.com still shows the "optimal" colo for me (RTT=27ms), but workers go through a different one. I did observe R2 latencies in the neighborhood of 100-200ms with the old colo as well.)
There is a cache in front of these requests and it helps a lot; however, sometimes the cache is poorly-behaved in the sense that it takes 5 or 6 writes before it actually stores a response, and evicts even frequently-requested resources.
I've observed KV read latencies of upwards of 300ms, and just half an hour ago I had two requests 2 same-region R2 requests in a row have a latency of 900ms (as measured by the worker).
These occurences make workers very difficult to use for anything user-facing, as combining even a few of these requests can lead to requests that take seconds, which is very noticeable.
Are these kinds of numbers expected, and is there anything that can be done to improve them?
Internet Speed Test - Measure Network Performance | Cloudflare
Test your Internet connection. Check your network performance with our Internet speed test. Powered by Cloudflare's global edge network.
0 Replies