Make it so datastore doesn’t exhaust with autosaves

Hello devfourm,

I have an autosave system which works fine as it is, however, if lets say a player leaves before the cooldown for the interval between each save is reaches then it exhausts (saves during autosave and then tries to save when they leave). Is there a way to combat this? The system itself works fine, I just want to know if there’s a way to make that ‘impossible’, because I really don’t want any chance for my system to possibly fail if that happened to a player.

2 Likes

You could make it so it auto saves randomly.

For auto saving try this.

while wait(math.random(120,200) do
--saving code here
end

Or you could simply remove the auto save and just make it save when the player leaves the game.

What i meant is, imagine the server just auto saved the player’s data then that player left the game after 1 second, it will queue that request right? I want to avoid that…

Cause basically my system saves the player data on leave too

I believe it will queue that request. Because I’ve left my game right after it autosaved and it saved fine.

But what if i want to avoid that warning message? How can i hide that from the console atleast?

I’m really confused cause other modules like profileservice don’t go through this situation even though they use autosave?

You can’t avoid that message because there’s too many requests at once as it says in the message. You could make it not show up, but the request would still be in the queue.

1 Like

Any idea on how profileservice handles that? They don’t have any warn messages or queue issues??

I am not familiar with profileservice. But if I were to guess, it probably would have a queue too.

1 Like

Would you recommend autosaving or just saving on leave is enough?

I would recommend saving on leave is enough.

1 Like

Don’t forget save on shutdown server!

1 Like

Profile Service automatically retries the requests that failed awaiting more time for available Datastore quota until it finally saves.

If you’re getting the warning, consider auto-saving less frequently, the quota provided by Roblox is more than sufficient.

1 Like

Well as i said auto saving is working perfectly fine, i just wanted a way to implement it with player leave, cause say you auto save right before the player leave… thats 2 requests right there.

leaving on save only would cause data loss to all the players.