Data Store GetAsync() problem

Hello everyone,

I recentlly realized that in my game “Game reviewer” I was using :GetAsync() function for every game I was loading on a front page:


(I load rating for each game)

I didn’t noticed it at first so I thought everything would be good but now that I see that, I will very shortly exceed the :GetAsync() limit for my data store (it is 70 per server per minute and I have only 1 person per server).

currently, all the data is stored in a separate key so for example if you have a game with ID of 111, all the data with reviews, user Ids, rating etc would be stored in a key with this ID. I also Can’t store everything in 1 key because I suppose it would take about 5000 posts (with player Ids, rating etc) to exceed the other limit which is 4MB per key.

here is how I store the data currently:

DataStore:UpdateAsync(tostring(GameId).."-Data", function(oldData)
		table.insert(oldData["Usernames"], plr.Name)
		table.insert(oldData["Reviews"], Review)
		table.insert(oldData["Dates"], os.date("%c"))
		table.insert(oldData["Ratings"], Rating)
		table.insert(oldData["UserIds"], plr.UserId)
		table.insert(oldData["PointAward"], false)
		table.insert(oldData["PostId"], PostId)
					
		table.insert(oldData["Tag"], PlayerCustomization.Tag)
		table.insert(oldData["BC"], PlayerCustomization.BackgroundColor)
		table.insert(oldData["TC"], PlayerCustomization.TextColor)
		return oldData -- Return it to save
end)

I know it might not be the most practical way but thats what I got (I’m not the best at it)

I was thinking about making a separate key or even a data store for ratings but I don’t know if thats a good idea. Please let me know what else can I do to get around this, maybe you got a better way to store reviews? (using external services to store data could also be an option but that does require a budget which I currently don’t really have)

If you want to test the game as it currently is, here is a link

Thx for reading, I hope someone will have some sort of solution for this one.

1 Like

A solution you could try is whenever a game’s data successfully loads check to see if the current request budget is less than a value (I wouldn’t recommend a very small value) and if not activate a loading state for the other games while waiting for the budget to increase like so:

if DataStoreService:GetRequestBudgetForRequestType(Enum.DataStoreRequestType.GetAsync) < 16 then
	-- Add a loading state for the next games here

	repeat task.wait(0) until DataStoreService:GetRequestBudgetForRequestType(Enum.DataStoreRequestType.GetAsync) > 32

	-- Remove the loading state here
end

it would work but the problem is, I wanted to have a couple of rows on the front page and it would look weird if over half of them would be loading all the time.

We must make-do with the budgets available unfortunately. You could try temporarily hiding the games that haven’t had their data loaded yet instead of using a loading screen if you want

Edit: Also you could save the data for games that loaded successfully locally in your game in a module for example to save on having to reload data for that game when the player goes back to the menu

menu loads only once per game, the only issue is that when you enter you would exceed the limit and when you are playing you would have a lot to spare. saving rating in game instead of loading it would also not work (if thats what you mean) because it changes all the time. I need to get at least 10 games per row to get loaded so when you first join the game, it would not look like unfinished or something (I don’t really think anyone would play it anyway but its better to fix issues like this even if its for my portfolio). and btw, I think that using other data store for rating is not a good idea beacause I would have to use Update Async Twice and I could also run out of these (its not used only for writing reviwes) + if I had over 1000 games in this data store and each game would have 5000 reviews, I could Run out of memory + it could take a while to calculate (making the game lag when it loads). at this point I am just scared about lag a lot but ig we’ll see

How many games do you want to have in your menu?

they are divided in categories so Most Popular games would be there, if possible then most rated, your favourited games, some simulatros stuff like that. Overall I think it could be like 400 games in total on this front page

(I did not add them yet but thats my plan)

and idk if you know it but you can also search for games by ID but they don’t show up in the front page so they are not the problem (they just use getAsync when you serach for them)

If you insist on having that many games loaded on the menu then I recommend ditching DataStores altogether and instead hosting your own server API with the data you want and using HttpService to send and retrieve the data from your API. Unfortunately I never done something like this before, but here in the forum I know for sure that there are topics that explain what you need to do this

I read forums like that because I looked into it but now the problem is hosting because it may be expensive at some point and I don’t really have any income from any source to even try it out. I could try making my own hosting on my PC or something but not sure how to do that. Now that I think about it, it sounds like a good idea to host it on my PC. I will search for something like that

1 Like

This topic by BriefYayyayyay seems to be very informative about this:

damn that is long, i will read about it in my free time tho. If thats why I need then I will set you as solved :sunglasses:

1 Like

You can store all game data into a table of multiple dictionaries, and directly save the table itself, it won’t go over 4MB don’t worry about that.

Here is an exemple

local Games = {
	Game1 = {
		["Usernames"] = 0,
		["Reviews"] = 0,
		["Dates"] = 0,
		["Ratings"] = 0,
		["UserIds"] = 0,
		["PointAward"] = 0,
		["PostId"] = 0,
		["Tag"] = 0,
		["BC"] = 0,
		["TC"] = 0,
	},
	
	Game2 = {
		["Usernames"] = 0,
		["Reviews"] = 0,
		["Dates"] = 0,
		["Ratings"] = 0,
		["UserIds"] = 0,
		["PointAward"] = 0,
		["PostId"] = 0,
		["Tag"] = 0,
		["BC"] = 0,
		["TC"] = 0,
	},
}

One dictionary take only 119 characters / bytes (this bellow).

Game1 = {
		["Usernames"] = 0,
		["Reviews"] = 0,
		["Dates"] = 0,
		["Ratings"] = 0,
		["UserIds"] = 0,
		["PointAward"] = 0,
		["PostId"] = 0,
		["Tag"] = 0,
		["BC"] = 0,
		["TC"] = 0,
	},

Considering the values will probably be more than 1 character, lets round it to 150.
So 4,194,304 / 150 = 27,962 < number of dictionaries / game stored you can have into your saved table.

If you still are afraid to go above the 4MB limit, you still are able to do multiple games pages, and do a table of dictionaries for each page.

1 Like

when I save a review I save context (up to 350 characters) UserID (like 8-10) and many other stuff which all adds up to over 400 bytes. But keep in mind that there can be up to couple thousand of those reviews
(1k reviews would be like 0.4MB) and we are talking about 1 game rn. Its only 10k reviews that can be stored inside of a game

(keep in mind you can review all games on roblox and more than 1 review per user so you can basically review every roblox game if you want)

Can’t you just limit the number of review to the 5 lastest ?
Having that much review can also make you go out the Read and Write data limits pet minute, and UpdateAsync use both of them.

what if 1000 diff player play it each leaving 5 reviews?

this is global data so all players share the same

Then you probably should delete reviews from data, otherwise you will never be able to save, load or update that much data.
Even if you can reduce the number of use of Async call, or don’t go above the 4MB limit, you still will go out the Throughput Limits.

the limits apply only for the current server so when I UpdateAsync there should be no problem with exceeding that but idk what to do about GetAsync. Btw do you know if there is HTTPS request limit?

Each server have their own limits, and each Async call on this server use this server limits.
I don’t know about HTTPS request limits.


hey, so I actually did read it but I don’t really understand how do you edit the data with this and I think I need to use other website for that so thats not really gonna fix the problem for now. I think I will stick to my current Idea with saving rating in diff data store so I can access it faster. I need to do some for i loop testing first tho. Thx for help, I might make you as solved later if no one will reply.

1 Like