How Would I decrease Lag In A 100 Player Server

So, I have a couple of main questions about this topic:

Would locally deleting other players characters that are out of visual and contact range decrease lag for that player? And would it have any side effects on anything.

Would locally deleting huge amounts of parts that are no longer visible for the player decrease lag, then later replacing back in those parts locally.

Any other tips on decreasing lag in a full server with a lot of parts would be really helpful.

2 Likes

I have a few things to ask, and say, about your question.

  1. In your second question:

That’s essentially turning on StreamingEnabled. Take a look at that.

I personally don’t know what this would do, but you should probably avoid it. I’d imagine it would create some problems.

By “lag”, do you mean ping lag or frame rate drops? You seem to be asking how to reduce frame rate drops in your game. There are three reliable ways:

  1. Reduce part count
  2. Turn on streaming enabled
  3. If you’re using a lot of meshes, make their RenderFidelity “Automatic” so it renders easily at a distance.

My game is a space travel game so everything is really spaced out, so streaming enabled isn’t really an option, I was thinking more of locally destroying all the parts in a planet while the player isn’t in the atmosphere. And I already have little to no meshes or unions or textures or anything in the game. And I’m talking about frame rate drops.

It seems like you might actually be looking for something called “chunk loading” at this point. I don’t have any articles or advice to give you regarding that topic, but you should try taking a look at it.

1 Like

As to your question about locally deleting parts, here’s an implementation I use in a few of my games that are higher part count, though it does have its drawbacks which I will outline.

I run a loop every x time (ranging from 1-5 seconds depending on the title and the needs) which checks parts, models, folders, etc. that I have tagged to load and unload locally. I move them from workspace into ReplicatedStorage and the reverse as needed. It basically does exactly what StreamingEnabled does, but allows you to control what is and isn’t loaded or unloaded at any given time, allowing you to preserve any views and such that you have - example of this in your case would be flying around in space and seeing planet/star silhouettes in the distance; StreamingEnabled likely would unload those whereas a custom implementation can leave a silhouette in but remove the detail the player will never see at great distances. However, there is a cost to reparenting something which is why I have a larger delay on running that loop as to not induce more lag while trying to reduce said lag. In your game if you have something like a warp drive or something you can add in a check when engaging that to load the location you are going to, or find another way to load that in. This is all done locally which does not reduce memory cost (actually can increase memory usage a bit), but drastically improves frame loading times which is where a number of players ‘feel’ lag.

The short answer is yes it will reduce lag - but don’t delete the parts. Just move them into ReplicatedStorage.

The only other two suggestions I have given the information you’ve provided and questions you have are the following: 1) go through your scripts and use the built in tools to try and optimize as much as you can there. You can often earn back a significant amount of performance through a lot of micro optimizations in your existing code. 2) Run some tests and see where your game functions best player count wise. If after all of your optimizations and tweaks still induce lag on players, see if its just not feasible to have 100 players in such a large game, but only your testing will be able to tell that for certain.

3 Likes

As people have already mentioned of course less part count try to optimize your code to run on the client side smoother. If you have meshes try to have as little triangles as possible so the client doesn’t have to spend a lot of processing power for it.

Thanks, that answers my questions for the most part. I was thinking that if you deleted and readded the parts into the game is would be less laggy than keeping them in replicated storage.

You can delete them and readd them, but the only way you could do that would be to involve the server or cache everything you delete as a cloned object in a table, both of which have some pretty major downsides. I personally use CollectionService tags to manage what can and can’t be unloaded, and the iterate through everything that has that tag to determine if it should or shouldn’t be loaded for the client to see. Just be careful of running this too often - moving thousands or tens of thousands of parts can and will cause lag in its own right but you can mitigate this by having it be a slower process or something that runs infrequently. There’s a post here that is both a great plugin to use if you’ve never used CollectionService before as well as a few code examples to see how it all can work together.