How much would it take to lag the server?

The planned player count for my game is 16 players, potentially if every player is in some sort of grass at once I’ll be running a while loop than runs every 1 second.

Every second it’ll check to see if the player is moving (by checking move direction), if they are then it checks if the player is in a battle (by checking their battle Id, if it’s a number they’re in a battle). If they are in a battle nothing happens.

Potentially there could be 16 of these loops going on the server at the same time.

Are the calculations here enough to cause lag? Sorry if this is a question that’s not able to be answered but I thought I’d ask instead of worrying about it all the time).

You may consider distributing the workload to LocalScripts, if this isn’t going to be something that needs to be hack-proof. (Also keep in mind that certain possible hack preventions need to be sacrificed for performance)

After that, it will potentially weed out more people to check that they are in combat before you check who is moving, since theoretically fewer people will be in combat. That will save a little processing time.

It’s an easy thing to change later. It will be fine for now, and if your game has issues down the road with lag, this will be really easy to change. I am a firm believer that premature optimization and eggnog are the root of all evil.

4 Likes

Could you not find an alternative method perhaps that may be less laggy? What’s the use case or purpose of the current method of your operations? Are there more things you can trust the client to handle over the server?

1 Like

The loop you are describing doesn’t sound very intensive. I often find it useful to remember that old RPGs used to run (mostly) fine with badly optimised scripts in every enemy (way more than 16). Doing some basic stuff with magnitude and conditions doesn’t compare, especially if it’s well written.

You don’t actually have performance issues at this point in time, right? Often unobserved performance issues are in our heads. Make your code as best as you can, but also be reasonable with your time and effort and wait (or make a catalyst) for evidence of bad performance if you’re unsure. We tend to overthink a lot heh.

If you really need to be convinced of the actual performance, get a group of people together or something (local server maybe? But that’s based on your PC) and just test it. You can always rewrite your code, at least early in development.

I’d be firing to the server every second and doing more calculations than I am originally so it’ll be more efficient to keep it server side.

You’re right. I think it’ll be fine but I’ll able to change the code pretty easily if lag becomes a problem. Thanks for the help!

1 Like