In simple, I’m creating a game where players can talk, interact and move-about with other players from completely separate servers. To achieve this, I’m sending data via MessagingService to each server then firing this data to the client (which handles the NPCs, etc) via a remote event.
However, there is a point where so much data is being sent to the client, the remote event becomes exhausted:
According to the wiki, “a Roblox server can only send and receive about 50 KB/sec of data to each client”.
How do you go about calculating the amount of data being sent per second, so that a cap can be introduced accordingly to prevent exhaustion (e.g. don’t send data to the client if 40 KB is exceeded for that second)?
To replicate the error, I fired off the event 1000 times on the server, instead of the norm of 1:
for i = 1,1000 do
network.UpdateClones:FireAllClients(data)
end
Originally it would only hit this amount when the player count began to climb to 100+
On the client:
for i,remote in pairs(network:GetChildren()) do
remote.OnClientEvent:Connect(function(data)
local currentTime = os.time()
if remote.Name == "UpdateClones" then
for username, records in pairs(data) do
lastActive[username] = currentTime
coroutine.wrap(function()
for i, record in pairs(records) do
updateNPC(username, record)
end
end)()
end
end
end)
end
I’ve adapting the server network so it will store all this information instead then fire it at each 0.1 second interval, ultimately avoiding the problem all together.
The buffer will be filled if you fire that event 1000 times in the same frame regardless of the size of the data you’re sending or whether or not it’s being processed by the client at all. data could be very small and that error would still be printed. That doesn’t really replicate the bug accurately.
EDIT: On second thought, you did mention 100 players… Spacing the events out would help after all.
EDIT2: To be clear, this isn’t the intended function of MessagingService. You’re inevitably going to hit some scalability issues at some point.