Lag spikes when people join

So for the past 8 months, when a new player joins and it prints they connected from the DarkRP logs in console, the server will freeze up for about 1-2 seconds, the more players on the longer it freezes for. With about 5 players it only freezes for a fraction of a second however with about 75 players on it can freeze it for even 3 seconds flat.

This is what it would look like when somebody joins on my server:

There were actually two people joining in that picture, which caused the two biggest lag spikes, shorter lag spikes also happen when people disconnect, thats the spike further to the left of the graph. (I’m looking at the interp graph for this, with the red spikes)

Originally there were lot’s more hooks on the PlayerInitialSpawn hook, i have cleaned them up and actually looked at most non-darkrp hooks to see if there is any bad code being run but i can’t find anything particularly bad, these are my hooks:

My server is running on 16 tps with what I believe is suitable rate settings and all in the config. It does use MySQL for a few addons including DarkRP and ARCBank.

I have tried removing all addons and re-adding them one by one, but the lag spikes just got gradually larger and no addon significantly increased them by a lot.
It is really difficult to debug it also because like i said i have to wait for like 75 people to join before it begins to lag it for more than a second, but it makes my server not be able to handle as many players as it should be able to without lag.

I have tried everything i can think of to try to fix this, could somebody please help?

It could be your SQL taking a long time to connect, or like you said, each addon’s slight bit of overhead hurts the performance.

probably ULX if it has a load of users, the issue is probs something reading/writing a large amount of data from the SQLite DB or data folder on playerinitialspawn

I have been through all the hooks, and the ones that read / write to files i put a timer delay on, but that didn’t make a noticeable different what so ever, also i understand MySQL takes times to do queries, but that wouldn’t hold up the entire process would it?

As Slowboi said above, if you have a rank which player after x amount of time gets put into, although its (on paper) a good way to find more trusted players, once there is 100+ people in that rank, it would be unbearable, and you would receive a hefty drop when using ULX and assigning other peoples ranks (as it displays a long, long, long list of names)

Edit:
We have brief spikes where the server freezes if, for example, a long list of logs (like 10k rows) is retrieved from the MySQL server (which in our case is located on the same rack is our dedi), far as i’m aware not much can be done about that.

We used to have a function which changed people’s ULX ranks when they joined, but not anymore, i don’t do any ULX stuff when they join but i guess ULX would be reading from the ranks file, and i can imagine it would be a pretty huge file. Should i try running the server without ULX?

how long has your server been running for?