As mentioned, I am trying to deploy Global Leaderboard System which may use origin DataStoreService. However there is a lot of limits about data fetch.
Could you please give me some suggestions about the data fetching frequency and how many boards you would deploy in a experience?
BTW, I would store players` data in the same experience also.
Appreciate for any help.
So if we look at the datastore limits
we can see that we have 5 + numPlayers x 2
requests per minute for GetSortedAsync
if we ignore the numPlayers x 2
we know its safe to use GetSortedAsync
5 times every minute
so if we wanted are leaderboards to update once every minute we would only be allowed 5 leaderboards
if you update the leaderboards every 2 minutes we could have a total of 10 leaderboards
so depending on how many leaderboards you want you would adjust the update rate
we also have to take into consideration SetAsync
because we must also set the players stat to the leaderboard we have a limit of 60 + numPlayers x 10
requests per minute for SetAsync
if we ignore the 60
and just look at the numPlayers x 10
this means each player can use SetAsync
10 times per minute
so we would use one of the 10 to save the playersData so now we have 9 left
that means if we have 9 leaderboards we could use SetAsync
for each leaderboard once every minute
one thing we must take into consideration is when the server is shutting down and needs to save all the player stats for all the leader board at once
and because each player has 10 SetAsync
every minute I think 9 leaderboards feels like the safest amount to have if your only using 1 other datastore key for the player for there playerdata
but this also would be effected by how often the players stat changes if you have a leader board for when a player does a rebirth then you would have to worry about SetAsync
because this does not happen very often and you could just SetAsync
as soon as they do the rebirth
so in short its hard to say how many leaderboards are safe to have as it depends on your game
but if you need to constantly use SetAsync
every minute to save the players stats then 9 would be a good number of leaderboards
1 SetAsync
for playerdata / 9 SetAsync
for setting leaderboards every minute
and you would do 5 GetSortedAsync
every 1 minutes for 5 leaderboards
and then you would do another 4 GetSortedAsync
the next minute for the other 4 leaderboards
a simple way to do that would be to just update each leaderboard with a 13.333
second delay between
local leaderBoards = workspace.LeaderBoards:GetChildren()
for index, leaderBoard in leaderBoards do
task.wait(13.333)
-- update leaderBoard here
end
this loop would allow for 9 leaderboards 120 / 9 = 13.3333333333333
For a general rule, I would recommend having a max of 5 leaderboard updates per minute, to leave room for other things such as auto saving different systems in your game. If you have more than 5 leaderboards, then just update them at different times.