You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Few issues I see when using hono-rate limiter with Cloudflare KV.
Workers KV has a maximum of 1 write to the same key per second. Writes made to the same key within 1 second will cause rate limiting (429) errors to be thrown. A retry might be needed.
Error: KV PUT failed: 429 Too Many Requests
Another issue is about setting the expiration, in Cloudflare KV, Expiration targets that are less than 60 seconds into the future are not supported. This is true for both expiration methods. When updating the kv, the expiration date might be less than 60 seconds from last time.
Error: KV PUT failed: 400 Invalid expiration of 1731388191. Expiration times must be at least 60 seconds in the future.
Finally, for the concurrent write issue,
"Due to the eventually consistent nature of KV, concurrent writes to the same key can end up overwriting one another."
"If concurrent writes are made to the same key, the last write will take precedence."
does this mean if concurrent requests come in from the same ip, the kv might not be able to increment properly?
The text was updated successfully, but these errors were encountered:
Yes, these are the limitations in the KV-based rate limiting, that's why I created support for the Durable Object Store too. The basic idea is that the KV is global and the Durable Object is regional, which helps it have an edge over KV.
Few issues I see when using hono-rate limiter with Cloudflare KV.
Workers KV has a maximum of 1 write to the same key per second. Writes made to the same key within 1 second will cause rate limiting (429) errors to be thrown. A retry might be needed.
Error: KV PUT failed: 429 Too Many Requests
Another issue is about setting the expiration, in Cloudflare KV, Expiration targets that are less than 60 seconds into the future are not supported. This is true for both expiration methods. When updating the kv, the expiration date might be less than 60 seconds from last time.
Error: KV PUT failed: 400 Invalid expiration of 1731388191. Expiration times must be at least 60 seconds in the future.
Finally, for the concurrent write issue,
"Due to the eventually consistent nature of KV, concurrent writes to the same key can end up overwriting one another."
"If concurrent writes are made to the same key, the last write will take precedence."
does this mean if concurrent requests come in from the same ip, the kv might not be able to increment properly?
The text was updated successfully, but these errors were encountered: