So Im using a combo of ProfileService and ReplicaService to save player data. Of course I know you need to use OrderedDatastores for global leaderboards, but how often should they actually update with the player data?
For something like a coin leaderboard, I would have to do something like this:
But how often should this actually be done? When a player joins, leaves, every 30 seconds, or a combination of a few? I dont want to throttle ProfileService, and its not exactly documented if GlobalDatastores and OrderedDatastores share read and write limits.
And also, for something like a donation leaderboard, should I update the OrderedDatastore every time a donation product is purchased, or the same way as the coins?
I would use a combination of when player leaves and saving every minute or two. I believe both Global and Ordered DataStores share the read and write limits.
As for the donation leaderboard, I would also save every minute or two – otherwise if someone mass-purchases a bunch of donations, you’re eating up a lot of the limit.
Also when the game gets shut down
If you want to save every so often I suggest every 5 minutes or after a big event you could also use MemoryStore if you teleport a player etc.
Alright, I ended up doing this:
Buying a donation product, or incrementing the coins adds a value to a cache.
Every 60 seconds, that cache is saved to OrderedDatastores using IncrementAsync. (which SHOULD prevent issues with the values overwriting themselves if another server tries to save the cache, if it doesnt then I will have to use UpdateAsync)
And of course the cache also saves when a server shuts down.
I have the leaderboards get the data also every 60 seconds, but on a 30 second offset. So it goes like this: