Hey everyone, I’ve been pondering network efficiency lately, and it seems that the go-to choice for many is BridgeNet2. I’ve delved into the documentation and start tests, but in my tests, it hasn’t proven as useful as I’d hoped.
Test details
I have waited 5 seconds on server before player added.
Bridge Net
server
local player = game.Players:GetPlayers()[1]
local bridgeList = {}
for i = 1, 100 do
table.insert(bridgeList, BridgeNet2.ReferenceBridge("myFirstBridge"..i))
end
while task.wait() do
for i = 1, 100 do
bridgeList[i]:Fire(player, {
message = "hello world",
test = {a = 1, b = 2, c = 3}
})
end
end
client
local BridgeNet2 = require(Replicated.Packages.BridgeNet2)
for i = 1, 100 do
local b = BridgeNet2.ReferenceBridge("myFirstBridge"..i)
b:Connect(function()
end)
end
result422.54kb/s
RemoteEvents
server
local player = game.Players:GetPlayers()[1]
local folder = Instance.new("Folder")
folder.Name = "Events"
folder.Parent = Replicated
local eventList = {}
for i = 1, 100 do
local r = Instance.new("RemoteEvent")
r.Name = "RemoteEvent"..i
r.Parent = folder
table.insert(eventList, r)
end
while task.wait() do
for i = 1, 100 do
eventList[i]:FireClient(player, {
message = "hello world",
test = {a = 1, b = 2, c = 3}
})
end
end
client
local events = Replicated:WaitForChild("Events")
for i = 1, 100 do
local r = events:WaitForChild("RemoteEvent"..i)
r.OnClientEvent:Connect(function(message)
end)
end
result453.47kb/s
The server attempts to send 100 events with a standard data table every tick, but the results are not as distinct as expected. Does the size of 30kb really matter to anyone?
Perhaps there are some aspects I overlooked, such as the non-scientific nature of my testing. Can anyone share their opinion? Thank you very much.
No, you don’t need it, but you might want it. The performance aspect is great, but the actual highlight is that it abstracts a lot of annoying aspects of remotes, while keeping it advanced enough. The key reason I use libraries like these is being able to fire multiple select players and not all players without using loops.
No library can stop you from writing unperformant and unoptimized code. Looking at BridgeNet2, it seems to be more focused on events with a small amount of data being sent very often, thus it cuts out some of that data out to reduce overall data size, seemingly by packaging it all up into a single RemoteEvent with a cost of 9 bytes, instead of the 9 bytes being multiplied by the amount of events.
Therefore, I think the best test would be to try this on a real game that is sending a wee bit too much data per second (I’ve heard that things break down at 80kb/s, with the data sent in RemoteEvent clogging up the queue for things like physics or other instance replication), instead trying to bruteforce a ton of data and expecting it to be the end-all be-all.
As far as I can tell, you haven’t tested the part where the alleged “75%-80%” optimization comes from
You are just sending huge amounts of data, when that isn’t where the percentage is coming from. It’s coming from how long it takes for the data to get to your code after being received by the engine.
Some frameworks/libraries/whatever aren’t going to be useful to everybody, they fit a specific niche that, likely, the author of the library would find useful in their own projects. Just because a library is “good” doesn’t mean you have to use it, and neither is it mediocre just because you couldn’t find a use for it. I personally don’t use it because I don’t feel the need to, but clearly other people value it.
Oh, thank you very much, I just noticed my error, but the pictures in that post caught my eye. Can these pictures be real? I was testing the same aspect, but it didn’t turn out like the pictures.
I think so, the math seems to work out. The formula would be (packet size for an event) x (number of events) x (number of frames in a second). Remotes have a default of 9 bytes overhead, there are 200 events, and, by default, Roblox runs at 60 FPS, resulting in:
9x200x60
bytes per second, or 108000 bytes/s. Converting that to kilobytes per second (kb/s with division by 1000) gives us 108kb/s, which seems close enough.
Then, with BridgeNet, it’s just 9x60, as there’s only one RemoteEvent, which is 540 bytes/second or… 0.54 kb/s? There’s seemingly an overhead of 26 kb/s from Roblox itself, I suppose some of it is lost when under high stress to explain the difference in the first image.