How can I optimise my server to lag less when players are exploring new areas?
Hi there,
I'm having a lot of lag issues specifically when my players are exploring new regions. If people move far enough, the server essentially locks up and prevents anything from happening for sometimes minutes.
How can I best rectify this?
51 Replies
Thanks for asking your question!
Make sure to provide as much helpful information as possible such as logs/what you tried and what your exact issue is
Make sure to mark solved when issue is solved!!!
/close
!close
!solved
!answered
Requested by element3329#0
Pregen and worldborder
Are you using paper on a newer version of mc?
Paper 1.21 I believe
I should pregenerate with Chunky?
Ye
Its lagging a lot even when people fly around pre-generated areas
Use 1.21.1 asap
If they're flying with elytras it hurts the server bad
Will this fix the lag?
If you have high view/sim distance and a slow cpu etc then yes loading itself can be heavy
No
1.21 just has dupe, chunk ban etc
Chunk ban?
Crashing players who enter certain chunks intentionally
Ah I see. All of my players are close friends so not an immediate concern, but I'll get around to updating this weekend. Just concerned about my plugins
Slow disk performance, and non pre-generated worlds are the biggest cause of lag when exploring
Same with high view/sim distances
So you think I should lower sim distance? View distance I'd like to keep around 10 so my players can see well, since we average only about 5 players at a time
10 should be fine, it's the default/recommended
You can provide a spark report if you want us to see if it's world generation or loading that is causing the actual lag
Alright, I'll go do a bit of what I was doing when it was lagging, and I'll upload a 5 min report
!spark
Spark Profiler
Spark can be used to see why your server or client is lagging.
Users can share a spark report via
/spark profiler start --timeout 300
which creates a report after 5 minutes. The spark report is useful in debugging why your server is lagging, so ideally you should always provide one while asking for support.
Download | Website | DocsAdmincraft Canned Responses
Here we go
spark
spark is a performance profiler for Minecraft clients, servers, and proxies.
Spark Profile Analysis
These are not magic values. Many of these settings have real consequences on your server's mechanics. See this guide for detailed information on the functionality of each setting.
❌ entities.spawning.despawn-ranges.monster.soft
Decrease this in config/paper-world-defaults.yml.
Recommended: 28.
❌ entities.spawning.despawn-ranges.monster.hard
Decrease this in config/paper-world-defaults.yml.
Recommended: 96.
❌ entities.spawning.despawn-ranges.underground_water_creature.soft
Decrease this in config/paper-world-defaults.yml.
Recommended: 28.
❌ entities.spawning.despawn-ranges.underground_water_creature.hard
Decrease this in config/paper-world-defaults.yml.
Recommended: 96.
❌ entities.spawning.despawn-ranges.water_ambient.soft
Decrease this in config/paper-world-defaults.yml.
Recommended: 28.
❌ entities.spawning.despawn-ranges.water_creature.soft
Decrease this in config/paper-world-defaults.yml.
Recommended: 28.
❌ entities.spawning.despawn-ranges.water_creature.hard
Decrease this in config/paper-world-defaults.yml.
Recommended: 96.
❌ misc.redstone-implementation
Set this to "ALTERNATE_CURRENT" in config/paper-world-defaults.yml.
❌ chunks.entity-per-chunk-save-limit.experience_orb
Set a value in config/paper-world-defaults.yml. Recommended: 16.
❌ chunks.entity-per-chunk-save-limit.snowball
Set a value in config/paper-world-defaults.yml. Recommended: 16.
❌ chunks.entity-per-chunk-save-limit.ender_pearl
Set a value in config/paper-world-defaults.yml. Recommended: 16.
❌ chunks.entity-per-chunk-save-limit.arrow
Set a value in config/paper-world-defaults.yml. Recommended: 16.
Requested by element3329 • Page 4 of 4
Your launch flags need improving, and your server is about to oom
Should I just go and do all of these recommendations?
I think I am already using Aikar's flags so I don't know why it says I'm not.
These are the flags I have on my PebbleHost startup panel
-Xms5120M -Xmx5120M --add-modules=jdk.incubator.vector -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -jar server.jar --nogui
I used what was recommended from https://flags.sh/But ignoring that
Those are not the flags the server was started with at least
Interestinggg....
Did you restart it after changing the flags?
I believe I did
I'll do another restart now thought just incase
But yeah, garbage collection is mainly what's eating your performance, not anything server related
(or at least it's hard to see with how much garbage collection is impacting it)
What even is garbage collection? 😄
Java has it's own memory pool it manages, every now and again it goes through that pool and checks for stuff it no longer needs
Is there a quick way I can tell if my server is starting up with the right flags?
Just start a new spark profile and check the JVM flags tab
Hmm.. It's still got the default ones
Are you able to show where you set them in the panel? (as long as it doesn't show anything like your IP, etc.)
In regards to these flags too, if your plan from Pebble is only 5GB your Xmx should only be ~4GB, so you may want to update it to 4096M, and your Xms should match the Xmx value Looks like the UI does this automatically, good job Pebble.
This is what I've got on my panel, I've got a 5GB subscription
That does look like the right place to set them
You can't see the full text but its what I posted here
Unsure why they're not applying though
When I pasted them from flags.sh, I used the 'java' section, is that correct? Or should I have used windows or linux/mac
Yeah, you'd just take everything after java, so
-Xmx...
all the way to before -jar
as I assume pebble adds the -jar
part themselves (by how it's worded)Yeah, that's what I did I believe
I've made a support ticket with PebbleHost to see if they can look into it for me. In the meantime, should I apply the changes suggested by this spark profile?
If I'm being 100% honest, outside of garbage collection, your server appears to be running super smoothly
They aren't magic numbers, and can negatively impact gameplay, so I'd recommend waiting to see if you still have issues after the flags are fixed.
(for reference, without garbage collection, you're running at 9.5ms per tick on average, meaning your server could be working 5x harder before you start noticing any lag (50ms per tick is when the tps drops below the expected 20))
Alright, awesome 🙂 thank you for letting me know! I'll see if that ticket bears fruit and then hopefully it'll sort itself out
🙏
Alrighty, the Pebble admins got it sorted at last so the flags now apply
spark
spark is a performance profiler for Minecraft clients, servers, and proxies.
Spark Profile Analysis
These are not magic values. Many of these settings have real consequences on your server's mechanics. See this guide for detailed information on the functionality of each setting.
✅ Your server isn't lagging
Your server is running fine with an average TPS of 20.
Requested by element3329 • Page 1 of 4
How does this look?
They applied some flags of their own, so I just would like someone to have a once over and let me know if there's anything amiss
Looks a whole lot better
There are still some g1 old spikes every ~18 minutes, which may be worth investigating, but your average tps has no nasty spikes anymore
Awesome. What would you recommend I do to deal with those g1 old spikes?
Is it a flag change?
It would be, but I have no clue what flags affect it
Alrighty, no worries 🙂 thank you!
Really appreciated your help with all this
!answered
post closed!
The post/thread has been closed!
Requested by element3329#0