Is there any difference in performance between one single RemoteEvent for all players or a RemoteEvent for each player?

Generally if I have a particular event that every player will generate, I create one remote event and one script to handle all the remote events being received from every player. It seems more straightforward and more elegant. But then I got thinking, and this may be a stupid question, but could players see a quicker response on the server to the event they created if they each had their own separate remote event? Can a remote event get “bogged down” if receiving multiple requests from multiple players, resulting in some players seeing a larger delay before their event reaches the server? I know the server would still then have to handle each of the individual remote events for each player, so it’s probably still around the same workload if not worse, but possibly depending on how the server handles things, maybe multiple remote events with a lower rate of use could mayyyyybe be faster than how it handles one remote event with a very high usage?

Just a thought, probably a dumb one, but I’m really bad when it comes to knowing whats heavier or lighter on the performance load.

8 Likes

The best way to answer performance questions is to try it! I’m doing that right now with my entity-component-system helper. Even the best of us sometimes think performance of some operations are much worse or better than they actually are. When I was an intern at Roblox, developers told me that crossing the bridge between Lua and C was really slow. I did some testing and found out that trivial operations with Vector3’s are much faster than trivial operations with tables with x, y, and z and if I remember correctly even faster than having x, y, and z as upvalues. It was quite a surprise to everyone. In the world of performance, good data is key!

5 Likes

Yes, there is a massive performance difference. I found this out when I tried to make a game on just a couple remote events. When about 20 people played at once, the remote event scripts took seconds to process as multiple players firing the same remote event very often would throttle them.

Now I just create a script and attach a remote event to it for every player which connects to the game. This way the remote event script doesnt get throttled as there’s always only one player firing it.

(edit: I don’t think I made it clear enough, but I believe it’s the script which runs the remote event code and not the actual remote event which gets throttled)

16 Likes

I’ve generally also been conditioned to one script and one remote, but lately I’ve taken a liking to “localized networking” (I do the front and backend in StarterCharacterScripts and keep remotes in there). From my understanding, as vsnry said, there is a performance difference. Put this into concept:

  • One remote, one script, everyone’s firing that remote x amount of times every y seconds or z action
  • One remote per player, player only calls their own events, only one player using that remote

Typically it’s considered “good practice” to set up your networking in the classic style of remotes in ReplicatedStorage, but other methods are acceptable. I’d experience less trouble if less people are calling a frequented remote.

I can tell you what trouble I had trying to be super sophisticated and run my entire game on 5> server scripts, about 4 remotes (bindable and remote events and functions) and 6> local scripts.

Consider this too - the reason why most tool systems put their remotes and such in the tool itself and why a minority of them do the classic ReplicatedStorage method.

6 Likes

hmm, interesting. I had an early test session of the game I’m developing with a full server. The game seemed fine for me but some of the others were complaining about some lag. The game broke cause of a bug and I had to shutdown the server and try again.

In the second server, I experienced some delay but it only seemed like certain things (specific events) were delayed and not others. But my internet was just fine and wasn’t lagging. And some of the others also complained about lag but some said it was just fine.

So I’m thinking maybe the first time I was lucky and got early priority on the remote events, and the second time I was less fortunate and was having some of my events be delayed due to them throttling from all the other player requests, and I happened to be one of the last players getting through to the server for those events?

I guess maybe my question wasn’t so lame after all. Definitely going to try this and see if I notice a difference in performance.

Have you tried running your game on a lower end device like a tablet or phone?

No, cause I haven’t coded my game to work on touchscreen yet.

I don’t believe this. Are you sure your code isn’t yielding? Have you tried moving remote code blocks into coroutines? Remotes shouldn’t throttle on an individual basis.

1 Like

You can try it yourself. Run all of your server code on 1-2 scripts and then run the same server code on a script for each individual player.

1 Like

Would this work with a single server script + multiple remote events for every single player aswell?

My game has a massive script that handles this stuff with over 2000 lines of code, so creating one for every single player is not a great idea.

Right now i am sending physics updates via 1 remote event which is easily being throttled due to the amount of parts my game can have.

Would creating a remote event for every player stress my game even more or would it make it run smoother or faster?

1 Like