Server lag getting worse? I found a way to clear some serious mem & cpu on mine.

Lag! Damn that shit right? I’m the owner of HELLHAWKS.COM with 1400 hours of Rust gameplay and I’ve seen ton’s of it! My server is on Multiplay. Over time it seems that the lag spikes get increasingly worse. Its especially common with Oxide. Typically Multiplay recommends creating a new profile, slowly adding plugins to find your problems, spending days trying to find the problem that typically escapes you on a new profile because, even with all the plugins re-added, things start working great again. But the biggest problem with creating a new profile, or doing server wipes, is the loss of your loyal players’ data. Many get discouraged when they lose everything they’ve learned. We’ll… I found a way to rejuvenate our server performance without losing the important stuff!

Granted there’s always some lag spikes. But they shouldn’t happen so many times an hour, or kick players out of the server, on a setup that already proved to be fast & efficient. Sadly even the best collection of plugins will see an increase of cpu/memory activity over time until the performance become’s unbearable. That’s what happened to us again the past few days. The server got so bad that even restarts couldn’t fix it for more than 20 mins before a lag spike kicked someone out. I set out to find the problem by removing/swapping plugins but nothing seemed to really help. But then I realized that the only thing different between the profile and the new version of the profile was the player data (especially in Oxmin and our L.E.S. leveling system). By now it must contain a shitload of players right? It certainly did.

First I opened the oxmin.txt containing the Oxmin players data. Tried to clean it up with jsonlint.com but it crashed the script from the shear size of the data. Digging into the data, I found that many of the players had 0 or 1 connects and never returned. Looking at the L.E.S. player data I noticed most of the players never leveled past 1. Between the two files there was TONS of junk player data. But too much of it to clean up by hand so I wrote a quick JavaScript form that allowed me to paste the JSON and clean up these extra players with one click. When I tried the clean code on jsonlint it worked without error so I pasted the data back to the files. After restarting the server I saw a big difference in the cpu/memory. Impressive enough that I figured I’d even share my work in case other Legacy server owners want to try it themselves (please do let me know how it goes).

The page should stay up barring a power outage or something. Feel free to throw in any suggestions. But do keep in mind that I created it, in just mins, to handle the cleanup job. It does its job well despite how simple and ugly it is. Just paste the code in the respective input box and click the button. The results will be output on the page for you to copy (try triple clicking it to highlight). Right now it just supports the Oxmin and L.E.S. player data files but that should be enough to put a dent in them lag issues. Or at least I’m hoping it does for you what it did for me. Just shutdown your server, clean up the files, save them back, start the server back up, then enjoy the improvement.

http://lee8oi.hellhawks.net/rust-cleanup.html

Nice tool good work, for anyone who doesn’t know ctrl + a will make sure it’s all highlighted once you receive output

We have a cleanup tool that runs in the background. Our server hasn’t been rebooted in 2 months now.

Can clean up even more players from Oxmin by removing the id’s with no flags associated with them. Form now does that instead of looking for fewer connects. Strips the file down to next to nothing (besides the players who actually have flags set). That’s about as lean as that file can get. The removed players will get added back when they reconnect anyways.

Could you elaborate on what you are running in the background to ‘clean up’? Is it something available to other server owners or is it a custom solution you guys developed? What tasks does it perform to keep the server running so long without a reboot? My server is running great, but fat chance of seeing it run for 2 months without a restart. I could use whatever you are referring to.

Gr8 Server btw Lee8oi, played on it off and on for a month or so.

I’m glad we can provide a server worthy of a the praise. Lately we’ve been busier than ever and the server is taking it like a champ. I’m glad these little cleanup’s work. Stop in again sometime. Hopefully we’re still worthy :slight_smile:

Now cleaning Auto Admin players too. Didn’t realize it was keeping track of all the players despite them not being admins. Form removes any entries that are NOT admins.

PhantomNZ made the script… it’s not publically available.

It goes around looking for players that haven’t logged in for some time, removes them, and anything associated with them.

Also stops spamming of camp fires within certain radius, stops ramps over 5 levels deep being placed.

The biggest thing though is he has re-written virtually every popular plugin. The code people use to write these plugins is so bad it’s not funny. That’s where most of the issues come from.

Like for example:

  • Remove scripts how barricades and stuff explode if you leave it on
  • How the remove script goes through a building to remove stuff lags out the entire server
  • Teleport scripts were retarded

There’s so much more I’ve forgotten about, but yeah, the custom scripts out there are horrible.

I’ll ask Phantom to comment. I’ve asked him if he would ever release it, but he’s basically said no. He doesn’t want to support it.

So …

I wrote all the scripts on this server from scratch. Current script is about 4000 lines now. Not interested in releasing because I know I’ll just get hounded to update it, add features, support something, help someone use it / modify it etc. Plus it gives our server something unique.
I’ve spent a lot of time and effort going through and optimising every part of the script to absolutely minimise the amount of lag that is script based.

Anyway, as infused mentioned, most scripts are horribly inefficient. They might be OK on their own, but no way near the level I’m happy with. I avoid writing to files. Put everything into my own datastore which is a table in Oxide and wrote an API to read / write / remove / loop through things. This API also saves the data periodically using timers so file IO is minimised.

My cleanup scripts know how long people have been on the server, if they have a base or sleeping bag, if they just joined to go into our arena then logged out etc. My scripts also manage all the base sharing and door sharing. With all that in mind, I can run a cleanup operation that kills off any inactive players, gives me a list to delete the files off the server etc. You can use timers to ensure cleanup operations only happen when there are no players on the server too and to stop them when players join.

Right now, we’ve been running for over 2 months, have roughly 100 current players running at about 15 - 20 per night at any given time and the server is not laggy at all.

Oh and decay is disabled … at least for now. Have enabled it once over the 2 month period but didn’t give me the desired outcome.

Well thanks for the insight at least. I’m on a multiplay server so hacking up all the plugins won’t do me any good since they won’t accept them unless I’m a plugin dev. Not to mention I wasn’t interested in doing the plugin development knowing that so much is gonna change with Experimental anyways. I was mainly looking for some simpler solutions to keep my Legacy server going for the meantime. The players are content with the current setup. We reboot every day (can only change the files and reload, nothing running to clean up whats in memory). So far cleaning up the Oxmin players, the L.E.S. players, and Auto Admin/etc takes care of the worst of our lag as long as we reboot before the mem gets too high. If I could just clean up whats in memory we’d probably be running for months on end too.

Bugger.
Yeah I didn’t like Oxmin etc. Found it all too inefficient for my liking. I don’t use any of the published scripts now, it’s all just 1 big beast and designed for efficiency from the start.
We never even have to reboot the server. It got restarted last night by streamline, but before that was a few weeks ago when I messed something up.

Tested it on our server, server 3 days old found 456 player files o.O, so when de lagg starts we know what to do now.

Thanks for this bro!

Appears to be down for me now. If you need a machine to host this on, would be more than happy to do so! This has been a more than helpful tool for me!