Excessively Firing Remote Events/ Remote Functions

Is it okay to fire remote events or remote functions excessively? Will it crash your game? Does it need debounces? Because I watched videos on Youtube and no one use debounces in their scripts when firing remote events/ functions. If we need debounces, how to do so?

Doing anything excessively is harmful.

Are remote events a danger by themselves? No, if you handle them properly, fire when necessary, and introduce cooldowns. Under these conditions everything should run smoothly.

The old Dev Hub page used to mention the limit of 50 kB, respectively 50 000 bytes per player. That statement is no longer included, and the (new?) bandwidth limit remains unclear.

Each time a client fires a remote event, they send a script signal over the network (spending a bit of available resources). If the server has a connected listener, the callback function is ran (which also spends some resources).

As you can see, there are two main points to consider here.

  1. What size of the data is sent + how frequently and
  2. what does the callback function do + does it have a cooldown and other protection measures.

About the data sizes, I suggest you take a look at this post: ORE (One Remote Event) - #33 by Tomarty .

Always try to be resourceful yet practical.

The other aspect depends on how performance intense the called function is. Does it do a lot of calculations? Does it spawn parts? Is it critical to have a debounce to prevent abuse? Anything like that.

The YouTube videos you’ve seen are likely focused on other parts of development (related to the title), and don’t cover everything. It’s usually a good idea to protect remote signals with cooldowns.

Example
local cooldown = {}

remoteEvent.OnServerEvent:Connect(function(player, args)
	if cooldown[player] then return; end
	-- type check of all args
	cooldown[player] = true
	
	-- serious calculations here :)
	task.wait(2)
	cooldown[player] = nil
end)

As for remote functions, we can check the time of last request.

Example
local lastReqTime = {}

remoteFunction.OnServerInvoke = function(player, args)
	if os.clock() - (lastReqTime[player] or 0) < 2 then
		return;
	end
	-- type check of args
	lastReqTime[player] = os.clock()
	
	return true
end

-- cleanup
game:GetService("Players").PlayerRemoving:Connect(function(player)
	lastReqTime[player] = nil
end)
1 Like

How do you know the bytes per player?

And this definitely won’t cause a delay for other clients right?

Also, there are many posts around the Dev Forum referring to it. For some more clarification, this quote from a cool article can help (reading recommended).

I just realized I accidentally wrote data size 50 kB instead of rate 50 kB/s.


The delays for other clients normally happen because the server becomes laggy. The examples I sent can be utilized to prevent the (relatively expensive) functions from running too frequently.

@waves5217 summed everything up pretty well. I’d personally say that you dont have to worry about the kB/s limit unless you are sending data such as camera CFrames or using it inside of a loop.
If you are just using remote events to trigger a function from the client to the server, just include a debounce as stated above (Using a debounce is a good practice), then you should be good!

2 Likes

So the limit for firing remotes is 50 kilobytes per second. How do you see how many kilobytes per second each data is being sent? Can we see it in the Developer console/ script performance?

At least that’s what the dev hub used to say. The current situation is not clear.

An approximate estimation is displayed in in the performance tab, in play test, under Network - ServerStatsItem.

In game, some information about the network usage is accessed via shift + 1/2/3/4/5.

1 Like

Oh so it’s the Send kBps thing. (Revision)

I wonder if we can see players’ ping

Yes, the Send kBps should roughly estimate the network usage. Try launching a local server with two players (in studio), while firing a remote event on one client. Then observe Send kBps on server and the two players. Moving around the map would incrase the size of sent data too.

Sure, although that highly depends on other factors as well. Latency in game is accessible with shift + 1/2/3/4/5 all the same, and then there’s :GetNetworkPing() (server side).

Bear in mind that in studio, ping times are much lower than in actual game with a real server.

1 Like

Btw, so 50kB is the limit of sending remote data from the client to the server right? or the opposite?

And I think we also need to add debounces for bindables

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.