I was wondering if the limit on the amount of requests you can send to the datastore every minute displayed on Roblox’s documentation website is outdated.
If this was true, wouldn’t it mean that I would only be able to send 70 GetAsync requests a minute (60 + 1 x 10 = 70), yet below you can see me send 71 GetAsync requests in under 2 seconds.
There is a cache and cooldown of 5 seconds associated with get requests for the same key.
When the first get request is initiated for a specific key, it is added to a local cache on the server and a cooldown is initiated. Further get requests for the same key will not make a call to the datastore servers if the requests are triggered before the cooldown expires. Instead, these requests will return the cache and will not deduct from the request limit since no outside call was made. This means almost all of the Datastore calls in the picture were actually accessing the cache.
That being said, the get requests basically allow for 10 requests (disregarding the hard 60) in a minute per player…which is a lot. There is no reason to make a get request every 6 seconds for the same datastore key. Get the data, cache it on the server, modify the data in the cache, then save the cache periodically as well as when the player leaves.
In my testing I found the cache cooldown to be 5 seconds, not 6 seconds, though Roblox may have changed it in the mean-time (have not tested it thoroughly in a while).
@heavenswilI As stated you are only consuming 1 from the get request budget since you are making 1 remote call and then the next 70 requests after that are cached and do not actually make any remote call. The value you see in these 70 subsequent requests may be stale. You can check this by printing/viewing the budget for get requests.
Hi, round_edsquare. I am sorry for not making it clear that I am not sending those 71 requests to the same key; you seem to have missed the tiny code at the top of the outputted numbers: for i = 1, 71 do game:GetService("DataStoreService"):GetDataStore("Random"):GetAsync(i) print(i) end
I am actually sending 71 requests to different keys, hence my confusion on the topic.
Note that you don’t just get the per-minute budget but you also get a starting budget. (this budget also varies between in-game and in Studio)
The 71 requests easily fit into the 100 starting budget. (The 100 may have changed, just review the budget tab in the console to see what the actual values are, if different.)
It’s highly recommended to give that resource a solid read as it also includes situations that will increase the budgets such as using the command bar/plugins and backlogged budgeting.
Ah, now I understand; I had previously overlooked that part. Thanks for writing that article; it was of great help, as the Roblox documentation covers too little.