How to check in-game when you are about to exceed remote limits?

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:
image

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)?

I also want to know this too because despite having a limit to data size for multiple services we have no way to measure it.


One idea is to use JSONEncode to measure string size and see when it exceeds the limit.

Another idea is to send it to an External source and measure the data size there and collect data for comparing in a live game.

You probably should go with idea one since you won’t be passing other stuff than a JSON string anyways when using MessagingService.

1 Like

JSONEncode would indeed be the way to do it.

local HttpService = game:GetService(“HttpService”)
local info = {}
local SizeInBytes = string.length(HttpService:JSONEncode(info))
print(SizeInBytes)

One way you could approach your problem is to put all your EventData in a table and after each second check its size. (Then clear the table!)

Then you could indeed halt the data if it exceeds any limits or whatever, like you said.

I also agree with @RuizuKun_Dev that we would need a Roblox service to measure this accurately for us.

10 Likes

This sounds like the best approach, thanks!

That error isn’t because you’re sending too much data. It’s because you’re not processing the remote events at all in the client.

Mind posting the event handler for UpdateClones?

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.

1 Like

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.

2 Likes