I’ve recently been working on a new game, and have run into the issue where the server will be constantly slowed down, with 2-5 second lag spikes on top.
The lag issues stays manageable for about 20 minutes, then the server just… gives up.
Script runtime comes up to about 5% total at the max (very rare, most of the time 1% or lower), so I’m curious as to why the lag amounts to so much. I ran the server microprofiler and found this scattered about constantly, and I’d noticed the same problem in studio after leaving the game running for a while.
A few other notable things:
- There are enemies that spawn and despawn overtime, also despawning when killed by a player. The total amount of them comes to about 30. Some of the lag spikes are attributed to this, but there aren’t many parts, and spawning/despawning barely takes any script power.
- There are these Item Boxes that are also spawning and despawning. The server also lags when they appear/disappear, but less so than the enemies. Again, the spawning/despawning process barely takes script power.
- I’m using a few different collision groups to enhance the gameplay. The item blocks, players, and the enemies all use their own collision groups.
Yet, no matter what, the game always slows down to a crawl consistently. This makes me wonder if it’s some sort of memory leak, yet I haven’t seen any script lag that would point to that. I’ve searched for touched events, ChildAdded, DescendantAdded, and more, and couldn’t find anything related to that, even at runtime.
Is there any way that I can hunt down and reduce this type of server lag, or perhaps get a more pinpoint on what’s directly causing it? It’s an AFK type game, so I’d prefer if servers could last 8+ hours before needing to restart them. Right now it becomes nearly unplayable after 2.