# R2 Rate Limiting ## Context - 2 workers - api.nft.storage - api.web3.storage - 3 buckets used by both workers with given key formats - carpark-prod-0 => `${carCid}/${carCid}.car` - satnav-prod-0 => `${carCid}/${carCid}.car.idx` - dudewhere-prod-0 => `${rootCid}/${carCid}` - `/upload` and `/car` routes trigger writes to all these 3 buckets ## Monitoring ![](https://i.imgur.com/jDiyop3.jpg) ![](https://i.imgur.com/h5SoHJc.png) ### Observations - Pink user doing a quite significant number of requests and no significant errors happening - Green user starts performing a large number of requests, starting triggering a lot of errors in our API for R2 rate limiting - not only for this user, but other users are also affected - also, other project in same account (nft.storage) also started having rate limit errors - Error received in worker seems to indicate rate limit is based on the same object ## Questions 1. What is the actual rate limit in terms of requests/time? 2. How is rate limit applied? - Is it actually per object key, or any type of prefix? - Is this accounter per worker/bucket, or can it be at account level? - Looks like same prefix key in multiple buckets can have an effect... 3. What happens when we get over the limit and get rate limited? - Does this affect other buckets? - Does it even affect the entire account? ## What we need - We can work around a rate limit per key in a single bucket, but not if this affects other users/buckets. It is super unlikely that different users will generate same keys