Hello, fellow developers!
I’ve been a scripter for a popular Roblox game for a while. Datastores have always been an issue for the game, as other scripters before me made it rely entirely on badge checking in order to give exclusive items. This, combined with a LOT of badges and items there is in the game, makes the Datastore script run around 140 requests to BadgeService everytime a player joins, causing loading times from 2 minutes (with luck) to even half an hour. Not fun.
When I was tasked to improve this system, the best I could do is store a table in the players datastores that would contain every badge you already own instead of checking over and over, making it less and less requests the more badges you have and greatly improving loading times to around 63 seconds.
But obviously, this solution still isn’t optimal and doesn’t work the same for everyone.
I come to ask, is there anything else I could attempt to speed up the system? Is it over?
EDIT: It’s also relevant to keep old badges that are no longer obtainable still working. This means simply adding the items onto data when badges are also given will work, but not fully.
You can save badges once when they are first given, later you can add manual save or smth to prevent data loss, this way you can have 1-2 requests instead of 60
This would work at first, but it’s also important to mantain checks for older badges that are no longer obtainable in-game for returning players. Forgot to mention this in the post
You can create quick-check system that will check if player have old data store system, and if yes it will port it to the newer one, if statement will be lightweight soo go for it
Use badges instead of DataStore (i cant script alot so cant explain properly).
Use badges and check if player has the badge instead of saving data.
This helps optomizing
How about using ProfileService? This is more efficient as it allows you to collect data and load it all at once rather than calling DataStoreService one by one to load the data.
Migrate from badges to datastores, but still support the old badge system if someone joins who hasn’t already migrated. At which point load all the badges and then do whatever you need to complete the migrations. Data loading should take <1 second assuming good api coverage.