I recently re-coded my server browser to use a MemoryStore HashMap to keep track of a server’s status, details, and the players in the server. The problem is, I don’t understand why API requests with this call are significantly higher than my other calls.
For some context:
My server browser place is a 1-player server. The function that contains this call only fires upon the player entering the server, and every 30 seconds after the server is opened.
My game usually gets around 10 active players at a given moment, where about 1-3 of them are in the server browser place. In theory, I should be getting around 20 calls per minute but I’ve reached numbers over 1000.
Here’s the API Request Unit graph captured from the Analytics tab.
Here’s the code that contains the call in question:
function BrowserService:FetchAllServerDetails()
local ServerDetailsInHashMap
local success, err = pcall(function()
ServerDetailsInHashMap = ServerDetailsHash:ListItemsAsync(200)
end)
if not success then
warn("[BrowserService]: There was an error fetching server details: " ..err)
print("Trying again in 5 seconds.")
task.wait(5)
BrowserService:FetchAllServerDetails()
return
end
if not ServerDetailsInHashMap then
warn("[BrowserService]: ServerDetailsInHashMap is nil! Not listing anything.")
return
end
while not ServerDetailsInHashMap.IsFinished do
local ServerDetailsPage = ServerDetailsInHashMap:GetCurrentPage()
for _, ServerDetailsEntry in pairs(ServerDetailsPage) do
local ServerDetails = ServerDetailsEntry.value
BrowserService:UpdateServer(ServerDetails)
end
if not ServerDetailsInHashMap.IsFinished then
ServerDetailsInHashMap:AdvanceToNextPageAsync() -- I added a pcall after copy-pasting my code
end
end
end