Server lag when players join/connect

Hello!

So I’ve recently noticed when we hit around 30 players, the server tends to lag during the process of players loading models/ulx/etc… as this process affects the server performance. So, I was wondering if anyone had any ideas for whether it’s possible to have a script which will manage all of that and will slow down the process of loading the models/materials/ulxcommands/donation system/etc slower which will hopefully increase the server performance during the time of those players joining? Thanks for any ideas.

First, it would be a good idea to check out what’s running upon the player joining. You can see all hooks by doing this in the server console.

[lua]lua_run PrintTable( hook.GetTable()[“PlayerInitialSpawn”] )[/lua]

From this, you can figure out what’s going on. Another thing to try is running FProfiler while the player is joining.

If they’re freezing when they spawn in for awhile, then you’re flooding them with data and need to space it out either with sequential data or timers.

Thanks for that.

Here are the results:

[editline]28th August 2017[/editline]

I will try the FProfiler, all though, I’m unsure what it is. Thank you. And yes, the game does freeze for those who join awhile, however, it’s mainly other players which get impacted by those who join. It causes spike lag to other players whilst someone is joining (during the final stage of fully connecting to the server).



services.initSpawn


Unsure where this is from, we can find out by doing this in the server console:

[lua] lua_run PrintTable( debug.getinfo( hook.GetTable()[“PlayerInitialSpawn”][“services.initSpawn”] ) ) [/lua]

The rest of it is just usual addons which shouldn’t be causing any issues.

FProfiler will be your best bet. Open the menu and select “Server” in the top left, start the capture and get someone to join the server. After they have spawned in, stop FProfiler and sort the list by pressing the “Total time in ms (inclusive)” tab.

ULX has been known in the past to freeze servers upon someone joining, I’m pretty sure that was fixed a while back however.

Depends on how you store user data I believe. If ULX still just stores all the player group assignments in a single massive users.txt file then you’re boned unless you switch to SQL. I can’t remember though and my contact is AFK.

thats from my service system, all it does is check if a player is a service job, if so, it sends the active services :stuck_out_tongue:

here’s the code if ur curious

Yeah, We have massive files such as users.txt, I just never knew that with ulx you could switch over to SQL. Will do that.

By switching over to SQL, what actual difference does it make?

[editline]29th August 2017[/editline]

Yeah, well, I’m assuming it is ULX which is causing the major lag upon connections.

Here are the results for that lua_run:

Bizzy Services is https://github.com/bizzy-pac/bizzy-services

Line 329 appears to be this.

[editline]29th August 2017[/editline]

Could that be potentionally causing lag upon connection? If so, I’m more then happy to remove it, however, it’s quite useful of an addon when it comes to RP.

Switching to SQL lets you asynchronously read in user data in a fast and efficient way that will never lock up your server. Reading in and parsing a massive users.txt is slow and synchronous (halts the server until finished) and the bigger it gets the worse it will be. You will notice this issue quicker if your ULX setup assigns all new users to a default group since it adds every user whether or not they even ever come back.

Also when I say SQL I refer to something my mysqloo or tmysql4 (binary modules) which fully support async usages. The built in SQLite module does not have that functionality unfortunately.

Changing over to MySQL has reduced the major lag received upon connections, thank you all so much and I hope this thread could help someone else out there in the future. :slight_smile: