So I am building a cross-server marketplace for a game. I have thought of many and many solutions and this is just another solution I am treading the water on as a potential candidate
My question is 3000 players for example all called updateAsync on a key, how would the operations take place, and is it possible for data overwritten?
Going by the docs it will retry if it fails, but I am unsure of the nature when so many updates occur at the same time. Do other updates basically fail and try again because of the other servers attempting a change?
context: I would store all items in the marketplace under a single datastore and when a user buys a item it would update the entire datastore of the item at said index.
As far as I know, Roblox has limited how many times you can use any methods of GlobalDataStore Classes, for UpdateAsync its 60 + (numPlayers × 10) per minute and for me I don’t think it’s a good solution to update the key each time a player buy something, they could just do that many times from diffrent servers and most likely the operation will fail, I recommend doing that only when the server shutdown or the player leave as this reply said:
but if you wanna unsure that the data will be saved and reffering to this documentation, you can determin if the data updated or fail to update based on what did the UpdateAsync method returns, if it’s null means it faild so you can do like:
succ = GlobalDataStore:UpdateAsync(key,value)
again I don’t think this is a good idea, a better solution is to use MessagingService to communicate between servers and tell them that the player bought that item and it should be removed from the store or something, and you can update the data when one of the servers shutdown.
Yes, but in the docs they said The function will be called as many times as needed until the data is saved or until the callback function returns nil and also said If the callback returns nil, the write operation is cancelled and the value remains unchanged so this is a good way to esure that the operation does not get cancelled
because they did not mention when that happen.
Also the limitation on messaging service is less than data store service so it’s a better solution anyways.
IIRC, there was a limit on how many times any given key can be read / modified within a short time period.
Instead of saving everything to one key, could you use OrderedDataStore to keep track of different keys, then by getting the key off OrderedDataStore, access a normal datastore that then stores in the information for a particular item on the marketplace…