Is UpdateAsync supposed to fire more than 600 times on ProfileService?

Something just doesn’t add up right here. Isn’t it a bit overboard to call on datastore more than 600 times when just once is enough? I’m using ProfileService but when I look at DeveloperConsole I’m seeing DataStore methods like UpdateAsync get called more than 600 times and then increasing.

ProfileService taking more than 600 UpdateAsync

Is there something wrong with my ModuleScript?

	--- The Stats the player will start with ---

local DefaultTable = {
	Orientation = "Portrait",
	cash = 0;
	cps = 100;
	click = 50;
	PlotOwned = {},
	House = {
		SuburbanHouse = 1	
	},

	BuildingOutput = {0.1,0.3,1,5,35,};
	totalBuildings = {0,0,0,0,0,0};
	BuildingCost = {1,100,1100,12000};
	FinishedTutorial = false,
}


	---- Variables ----
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local ProfileService = require(script.ProfileService)
local ProfileStore = ProfileService.GetProfileStore(
	"GlobalPlayerData",
	DefaultTable
)

	---- Player Data Server ----
local Profiles = {}

local DataManager = {}

function DataManager:Get(player)
	local profile = Profiles[player]
	if profile then
		return profile.Data
	end
end

local function clock(profile) -- The actual clock that handles the money
	RunService.Heartbeat:Connect(function(DeltaTime)
		profile.cash += profile.cps * DeltaTime
	end)
end

local function Clock(profile)
	local CashFlow = ReplicatedStorage.CashFlow
	while true do
		
		wait(10)
	end
end

local function SetScreenOrientation(player,Orientation)
	if player or Orientation then
		local ToEnumOrient = Enum.ScreenOrientation[Orientation]
		ReplicatedStorage.SetScreen:FireClient(player,ToEnumOrient)
	end
end



----- The important stuff related to ProfileService -----
local function PlayerJoining(player)
	local profile = ProfileStore:LoadProfileAsync(
		"User_" .. player.UserId,
		"ForceLoad"
	)

	if profile then
		profile:Reconcile()
		profile:ListenToRelease(function()
			Profiles[player] = nil
			player:Kick("Player: " .. tostring(player) .. "left the game")
		end)
		if player:IsDescendantOf(Players) then
			Profiles[player] = profile
			SetScreenOrientation(player, profile.Data.Orientation)
			coroutine.wrap(clock)(profile.Data)
			
		else
			profile:Release()
		end
	else
		-- There was an error when retrieving player DataStore, Release will not work
		player:Kick("Error when retrieving" .. tostring(player) .. "GameData")
	end
end

local function PlayerLeft(player)
	local profile = Profiles[player]
	if profile then
		profile:Release()
	end
end

function DataManager:PlayerJoin()
	Players.PlayerAdded:Connect(PlayerJoining)
end

function DataManager:PlayerLeaving()
	Players.PlayerRemoving:Connect(PlayerLeft)
end

function DataManager:Proof() -- Apparently players joining faster than scripts run is a thing.
	for _,player in ipairs(Players:GetChildren()) do
		coroutine.wrap(PlayerJoining)(player)
	end
end

return DataManager
1 Like

Seems fine. That ProfileService module seems pretty well built. I wouldn’t worry about it. ROBLOX throttles calls to those methods anyways, so you can’t really overdo it even if you tried.

2 Likes

As an added note, those numbers represent the budget LEFT to use. If it’s increasing, that is a good thing.

You can find information about how the budget is calculated for various datastore methods here: Documentation - Roblox Creator Hub (Scroll down to Limits)

If you want to check the current budget, you can use :GetRequestForBudgetType, which is what the dev console internally uses.

3 Likes