NetRay - High-Performance Roblox Networking Library

I did. I just refractored it cause why would u say 1e2 :joy: Just say 100

This is not my testing place; I just ran it on my PC

Blink:


Zap:


ByteNet:


Packet:


NetRay:


Netray:

Results:
Screenshot 2025-04-05 202259

Overview,

  • NetRay performs the best for bandwidth uses; however, it did use the most CPU for struct of number,s which I will be trying to improve, resulting in high ping
  • Netray is slower, but this is intentional as it has internal features that result in this increased time. There will be an option in the future to skip the checks entirely, and it would result in similar timings

I will be trying to bring the CPU usage down soon etc, The testing place is the one Suphi provided I just ran it myself

Additional info: Rate limiting rejects the entire event; however, we know it hasn’t, as the log has not outputted the warning, and the CPU usage is increased, meaning it’s working.

Code for client server firing

function ClientEvent:FireServer(data)
    -- Check throttling
    if not self.ClientManager:CheckOutgoingThrottle() then
        warn("[NetRay] Request throttled: too many outgoing requests")
        return
    end
    
    -- Type checking if enabled
    if self.TypeDefinition then
        local typeCheckResult = TypeChecker:Validate(data, self.TypeDefinition)
        if not typeCheckResult.success then
            error(string.format("[NetRay] Type validation failed for event %s: %s", self.Name, typeCheckResult.error or "Unknown error"))
            return
        end
    end
    
    -- Run middleware
    local processedData = self.ClientManager:InvokeMiddleware(self.Name, data)
    if processedData == false then
        -- Middleware blocked this event
        return
    end
    
    -- Circuit breaker check
    local circuitBreaker = self.ClientManager.CircuitBreakers[self.Name]
    if circuitBreaker and not circuitBreaker:IsAllowed() then
        if typeof(circuitBreaker.Options.fallback) == "function" then
            circuitBreaker.Options.fallback(data)
        end
        return
    end
    
    -- Let DynamicSender handle the optimization, serialization, and compression
    local method = DynamicSender:Send(self.RemoteEvent, processedData or data)
    
    -- Log event dispatch if debugging is enabled
    if self.ClientManager.DebugEnabled then
        print(string.format("[NetRay] Event %s fired with method %s", self.Name, method or "DEFAULT"))
    end
end

Log

  20:11:33.209  Booleans  -  Client - Benchmark:16
  20:12:28.222  Blink:   0.000043  -  Client - Benchmark:29
  20:13:23.237  Zap:     0.000088  -  Client - Benchmark:42
  20:14:18.251  ByteNet: 0.000101  -  Client - Benchmark:55
  20:15:13.264  Packet:  0.000172  -  Client - Benchmark:68
  20:16:08.264  NetRay:  0.004174  -  Client - Benchmark:81
  20:16:08.265  StructOfNumbers  -  Client - Benchmark:16
  20:17:03.278  Blink:   0.000147  -  Client - Benchmark:29
  20:17:58.309  Zap:     0.000409  -  Client - Benchmark:42
  20:18:53.356  ByteNet: 0.000606  -  Client - Benchmark:55
  20:19:48.388  Packet:  0.001173  -  Client - Benchmark:68
  20:21:43.924  NetRay:  0.034760  -  Client - Benchmark:81
  20:21:49.976  Disconnect from ::ffff:127.0.0.1|50215  -  Studio
  20:21:49.978  [NetRaySender] Game closing. Flushing remaining batches...  -  Server - DynamicSender:568
  20:23:22.331  'Benchmark (1).rbxl' auto-recovery file was created  -  Studio

Aditional Confirmation


Benchmark (1).rbxl (351.2 KB)


i had to speed up 5x the vid due too long (over 6mins)
avg kbps & fps taken is 0.5s, while roblox frame manager is 1s… why 0.5s instead of 1s? for more accurates…

hey i get this error when making a event to learn this thing:ReplicatedStorage.NetRay.Server.ServerEvent:288: attempt to call missing method 'SendToMultiple' of table - Server - ServerEvent:288
and
16:14:26.282 [NetRay] Remote event not found: ReportLatency - Client - ClientManager:197 16:14:26.282 [NetRay] Failed to register event: ReportLatency - Client - ClientManager:227 16:14:26.282 ReplicatedStorage.NetRay.Client.ClientEvent:29: [NetRay] Failed to create ClientEvent: ReportLatency

i used the example script in the github.

1 Like

Could you provide your code so I could examine it

again, errors on setup. I copy pasted your example scripts and I get this error:

09:59:05.683  ReplicatedStorage.Shared.NetRay.Server.ServerEvent:288: attempt to call missing method 'SendToMultiple' of table  -  Server - ServerEvent:288
  09:59:05.683  Stack Begin  -  Studio
  09:59:05.683  Script 'ReplicatedStorage.Shared.NetRay.Server.ServerEvent', Line 288 - function FireAllClientsExcept  -  Studio - ServerEvent:288
  09:59:05.683  Script 'ServerScriptService.Script', Line 16  -  Studio - Script:16
  09:59:05.683  Stack End  -  Studio
1 Like

Updated v1.0.1

  • Fixed Fire Client Methods

Roblox
GitHub

Thank you to:
@Planet_Dad
@zak_isla

for noticing the issue

1 Like

Hasn’t there already been a v1.0.1?

1 Like

Yeah, I just fixed a typo, I forgot I renamed a function and didn’t update it in the server event script

Btw would it even be possible to use Signal+ for event connections?
You have stuff like middleware and priority.

1 Like

Most probably, yeah, I will eventually look into it. Right now, I am switching compression algorithms and the logic of the Dynamic sender to hopefully reduce network bandwidth further and CPU usage entirely

1 Like

Can you send me the place file so I can test myself?

1 Like

I want to use this plugin for my currrent project but both times I have tried to install it theres an error.

I am not sure this one is fully ready for for people to be using.

I like this simpler API than Packet, but Packet seems to be pretty stable and tested before sharing with the public.

I am hoping you get this sorted out eventually.

1 Like

Was the issue not fixed? Or is there another issue?

oh it probably was! I just already moved on. I will try again soon.

I do honestly prefer your API and I am not overly concerned with perfomrance. I just want something better and easier to use than manually making remotes. I also made my own simple module to handle it all, but i thought I would try something a LITTLE nicer :slight_smile:

1 Like

when i send something through netray using FireAllClients it warns me this: [NetRaySender] Cannot SendToMany: Targets list is empty or nil. - Server - DynamicSender:459

I tried using a string and other data types such as tables and instance and same problem.


i set up a print statement in the localscript for when it receives but doesnt print. Instead
it prints what i sent inside the dynamicsender along with the event name.

1 Like

I believe you have to provide a list of players to send to.

1 Like

thats for FireClient, my case is FireAllClients.

i looked up the documentation and it shows that i don’t need to include the player :FireAllClients(data: any)

1 Like

I’ll double check the server eventually module soon, it’s potentially just the wrong order of arguements being passed during sending the information

Can you confirm if your ServerEvent Module looks like this for :FireAllClients()

function ServerEvent:FireAllClients(data)
	-- Type checking if enabled
	if self.TypeDefinition then
		local typeCheckResult = TypeChecker:Validate(data, self.TypeDefinition)
		if not typeCheckResult.success then
			error(string.format("[NetRay] Type validation failed for event %s: %s", 
				self.Name, typeCheckResult.error or "Unknown error"))
			return
		end
	end

	-- Run middleware
	local processedData = self.ServerManager:InvokeMiddleware(self.Name, nil, data)
	if processedData == false then
		-- Middleware blocked this event
		return
	end

	-- Use DynamicSender to optimize batch sending
	local sendData = processedData or data
	local allPlayers = Players:GetPlayers()

	-- Use SendToMultiple for batch optimization
	local result = DynamicSender:SendToMany(self.RemoteEvent, sendData, allPlayers)

	-- Log the batch send if debugging is enabled
	if self.ServerManager.DebugEnabled then
		print(string.format("[NetRay] Event %s fired to %d clients with batch optimization", 
			self.Name, #allPlayers))
	end
end