How many datastores should I try to use?

Currently in order to save data for my roblox game I am using 16 different datastores, saving when the player leaves and once every 60 seconds. Will I run into problems using this many?

You should be saving tables of values into one datastore instead of using multiple datastores for different values. If you continue in this way, as you add more values, you get more and more likely to start hitting datastore rate limits.

8 Likes

You won’t really run into problems depending on how you handle data stores and in the end it’s up to you, but this is “unhealthy” knowledge to retain. Why is it that you have ended up using 16 data stores?

Ideally, what you want is to relegate all your data to a singular data store. You can use others depending on their use case, but you want to aim for as little as possible for the sake of your sanity and proper practice/know-how in your future works. You have some options:

  • Save a raw or JSON encoded table value to a UserId key
  • Make use of data store scopes (a pretty underrated-but-useful feature of data stores)
  • Save only what you need to save, get rid of the rest
1 Like

Having a different store for each aspect isn’t very efficient. I’d recommend using a dictionary to save data.

If you’ve already got a system in place that doesn’t manage data through a table (maybe through values) you can just add them to a table when the player leaves.

local SaveMe = {}
SaveMe.Cash = leaderstats.Cash.Value 
SaveMe.Exp = leaderstats.Exp.Value
— etc 
2 Likes

Just a question, so saving all data into a dictionary, and then saving that dictionary is the most efficient way to save data?

1 Like

Any idea at what the data store rate limit is? Can’t find it anywhere

1 Like

My game has a bunch of different types of currency, ingame items, and a few other things to remember. It ended up being pretty heavy in data stores.

2 Likes

Found it actually,

60 + numPlayers Ă— 10

is the limit on data stores.

Looks like I need to knock my 16 down to 10 otherwise I will be facing some issues.

1 Like

Couldn’t include it last night because the docs were broken.

3 Likes

Got my datastores down to 6, thank you for teaching me I can use a table like this!

2 Likes

Generally I make a new datastore for very specific uses, for example my game has a question submission system which uses a datastore to store pending questions, and a seperate one to store accepted questions. This is because the pending questions store is only requested if a moderator is in the game, and the accepted questions store is only requested very infrequently, only once per server.

A good rule to stick to is that data you are loading every time a user joins, and data you save periodically/ when they leave should be kept in a single datastore. Use dictionaries to store stats such as money, kills, inventory or whatever else you want. This way you’ll be unlikely to go over the datastore limit. For save files, make sure you use a seperate datastore as you can very easily go over the limit if you put your complicated saves in the same datastore as user stats and basic data.

2 Likes