[GUIDE] Server Optimization⚡

Discussion in 'Performance Tweaking' started by Celebrimbor, Nov 6, 2017.

  1. Celebrimbor

    Patron

    In memory of frash23

    Iɴᴛʀᴏ
    Spigot/Paper offers settings that greatly improve performance. This guide breaks down suggested values that get the most out of your server without compromising gameplay.

    Guide Updates
    - Updated for the latest Spigot/Paper 1.14.4
    - Last Update: Sep-10-2019
    - Change Log

    New server owner? Read my
    Lag Guide to understand your lag.

    Mᴀᴘ Pʀᴇ-Gᴇɴ
    Map pre-generation is critical to lag removal. Do it before you even touch your server files.
    1. Get the plugin WorldBorder
    2. Set a reasonable border distance.
    3. Command: /wb fill
    4. Wait...this may take hours depending on the map size. Ideally, you do this before the map is live as this will cause lag.
    5. Leave the border so new chunks never generate (cause lag).
    Bᴜᴋᴋɪᴛ.ʏᴍʟ
    spawn-limits
    Default: monsters:70, animals:10, water-animals:15, ambient:15
    Optimized: monsters:50, animals:8, water-animals:3, ambient:1
    Performance Impact: Medium

    ➫ While there is more to this than "mobs per player" (explained in PDF), lower values mean less mobs. Avoid going too low or the mob shortages will be noticeable. Subsequent values in the guide will make the reduction less noticeable.

    chunk-gc.period-in-ticks
    Def: 600
    Opt: 400
    Impact: Medium

    ➫ This unloads vacant chunks faster. Ticking fewer chunks means less TPS consumption.

    ticks-per.monster-spawns
    Def: 1
    Opt: 4
    Impact: Medium

    ➫ This sets how often (in ticks) the server attempts to spawn a monster. Slighty increasing the time between spawns should not impact spawn rates.

    Note: Only go higher if you have significant tick loss to the mobSpawn task.

    autosave
    Def: 6000 (usually)
    Opt: 6000
    Impact: N/A

    ➫ This enables Bukkit's world saving and how often it runs (in ticks). It should be 6000 by default, just double check it is not 0 (disabled). This is a gradual/queued task (no lag?).

    Note: If you use Multicraft or a plugin to run saves, STOP! They just run the very inefficient /save-all command.

    Worldsave Lag: If you have lag spikes from Worldsave, it is probably time to use Paper with its lag-free saving.
    Sᴘɪɢᴏᴛ.ʏᴍʟ
    save-user-cache-on-stop-only
    Default: false
    Optimized: true
    Performance Impact: Medium

    ➫ Should the server constantly save user data (false) or delay that task until a stop/restart (true)? This is nice TPS savings on Spigot (less on Paper since it's more efficient).

    Note: Take regular backups to avoid data loss in the rare event of a fatal crash.

    max-tick-time
    Def: tile:50, entity:50
    Opt: tile:1000, entity:1000
    Impact: N/A

    The optimized value disables this feature. The small TPS savings is not worth the potential damage.
    Damage? (click here)

    mob-spawn-range
    Def: 8
    Opt: 6
    Impact: N/A

    ➫ This sets the max mob spawn distance (in chunks) from players. After limiting spawns in Bukkit, this will condense mobs to mimic the appearance of normal rates.

    Warning: If your view-distance is 6 or less, set a spawn range 1 below that value. For example, if view-distance is 5, set mob-spawn-range to 4.

    entity-activation-range
    Def: animals:32, monsters:32, raiders: 48, misc:16
    Opt: animals:16, monsters:24, raiders: 48, misc:8
    Impact: Medium

    ➫ Entities past this range will be ticked less often. Avoid setting this too low or you might break mob behavior (mob aggro, raids, etc).

    merge-radius
    Def: item:2.5, exp:3.0
    Opt: item:4.0, exp:6.0
    Impact: Medium

    ➫ Merging items means lessground item ticking. Higher values allow more items to be swept into piles.

    Note: Merging will lead to the illusion of items disappearing as they merge together. A minor annoyance.

    nerf-spawner-mobs
    Def: false
    Opt: true
    Impact: Medium

    ➫ When enabled, mobs from spawners will not have AI (will not swim/attack/move). This is big TPS savings on servers with mob farms, but also messes with their behavior. A farm limiter plugin might be a better solution.

    Note: Paper has an option to force nerfed mobs to jump/swim. This fixes water push farms and keeps the TPS savings.

    item-despawn-rate
    Def: 6000 (5 minutes)
    Opt: less?
    Impact: Situational

    ➫ The time (in ticks) before a ground item is removed. While the TPS savings can be significant if reduced, it also impacts gameplay on servers where returning to dropped items is critical.

    Note: See Paper's alt-item-despawn-rate so you can target trash items (cobblestone) without clearing valuable items (diamonds).

    arrow-despawn-rate
    Def: 1200
    Opt: 300
    Impact: Minor

    ➫ Similar to item-despawn-rate, but for fired arrows. Some servers may want to keep arrows on the ground longer, but most will have no complaints from faster removal.

    Note: Paper has settings to reduce the gameplay impact of arrow removal. Leave this near default if you use Paper's despawn options.

    Pᴀᴘᴇʀ.ʏᴍʟ
    Note: Paper has async chunk loading/saving. If you have chunk or worldsave lag, maybe consider Paper.

    Warning: Paper is an unofficial fork and is not supported on Spigot forums. If you have issues related to Paper, report them on Paper's issue tracker, not on Spigot!

    max-auto-save-chunks-per-tick
    Default: 24
    Optimized: 6
    Performance Impact: Heavy


    ➫ This slows incremental chunk saving during the world save task. This is incredibly important for 1.14 servers with how inefficient chunk saving is in 1.14.

    Note: Be sure your save can finish between your autosave interval. Setting this too low might result in unsaved chunks. If you have 40+ players online, you should try to keep this at 8 to be safe.

    optimize-explosions
    Default: false
    Optimized: true
    Impact: Minor

    ➫ Paper has a very efficient algorithm for explosions with no impact to gameplay.

    mob-spawner-tick-rate
    Def: 1
    Opt: 2
    Impact: Minor

    ➫ This is the delay (in ticks) before an active spawner attempts spawns. Doubling the delay will not impact spawn rates. Only go higher if you have significant tick loss from ticking spawners.

    disable-chest-cat-detection
    Def: false
    Opt: true
    Impact: Minor

    ➫ Chests scan for a cat on top of it when opened by a player. While enabling this eliminates vanilla behavior (cats block chests), do you really need this mechanic?

    container-update-tick-rate
    Def: 1
    Opt: 3
    Impact: Minor

    ➫ This changes how often (in ticks) inventories are refreshed while open. Do not exceed 4 to avoid visual issues.

    max-entity-collisions (in Spigot.yml in some builds)
    Def: 8
    Opt: 2
    Impact: Medium

    ➫ Crammed entities (grinders, farms, etc.) will collide less and consume less TPS in the process.


    grass-spread-tick-rate
    Def: 1
    Opt: 4
    Impact: Medium

    ➫ The time (in ticks) before the server tries to spread grass in chunks. This will have no gameplay impact on most game types.

    despawn-ranges
    Def: soft: 32, hard: 128
    Opt: soft: 28, hard: 96
    Impact: Minor

    Soft = The distance (in blocks) from a player where mobs will be periodically removed.
    Hard = Distance where mobs are removed instantly.

    ➫ Lower ranges clear background mobs and allow more to be spawned in areas with player traffic. This further reduces the gameplay impact of reduced spawning (bukkit.yml).

    hopper.
    disable-move-event
    Def: false
    Opt: true
    Impact: Heavy

    ➫ This will significantly reduce hopper lag by preventing InventoryMoveItemEvent being called for EVERY slot in a container.


    Warning: If you have a plugin that listens to InventoryMoveItemEvent, do not enable.

    non-player-arrow-despawn-rate
    Def: -1 (uses Spigot arrow-despawn-rate)
    Opt: 60 (3 seconds)
    Impact: Minor

    ➫ Similar to Spigot's arrow-despawn-rate, but targets skeleton-fired arrows. Since players cannot retrieve mob arrows, this is only a cosmetic change.

    creative-arrow-despawn-rate
    Def: -1 (Spigot arrow-despawn-rate)
    Opt: 60 (3 seconds)
    Impact: Minor

    ➫ Like the setting above, but for player-fired arrows that cannot be retrieved (infinity bows).


    prevent-moving-into-unloaded-chunks
    Def: false
    Opt: true
    Impact: Medium


    ➫ Prevents players from entering an unloaded chunk (due to lag), which causes more lag. The true setting will set them back to a safe location instead.

    Note: If you did not pre-generate your world (what's wrong with you?!) this setting is critical.

    use-faster-eigencraft-redstone
    Def: false
    Opt: true
    Impact: Heavy


    ➫ This setting reduces redundant redstone updates by as much as 95% without breaking vanilla devices. Empirical testing shows a speedup by as much as 10x!

    Note: If you use a plugin to change redstone algorithms, consider replacing them with this option as plugins tend to break redstone behavior.

    armor-stands-tick
    Def: true
    Opt: false
    Impact: Minor

    ➫ Some items are viewed as entities (require ticking) since they interact with the world. Unticked armor stands will not get pushed by water (do you care?)

    Note: Paper also offsets item frame ticking instead of ticking all frames at once. This is not configurable, just enjoy the TPS savings with no gameplay impact.

    per-player-mob-spawns
    Def: false
    Opt: true
    Impact: Minor


    ➫ This implements singleplayer spawning behavior instead of Bukkit's random algorithms. This prevents the actions of others (i.e. Massive farms) from impacting the server's spawn rates.

    Note: If you lowered spawn-limits in Bukkit and notice shortages of animals and monsters, consider bumping those back up until you find a happy place.

    alt-item-despawn-rate
    Def: false
    Opt: true
    Impact: Medium

    ➫ Remove certain item drops faster (or slower) than the item-despawn-rate set in Spigot. This lets you avoid dedicating resources to ticking massive piles of garbage.

    Example of despawning cobblestone and netherrack in 15 seconds:
    Code (Text):
          enabled: true
          items:
            COBBLESTONE: 300
            NETHERRACK: 300
    Note: Make sure you use the Spigot material list when adding items.

    anti-xray.enabled
    Def: false
    Opt: true
    Impact: N/A

    ➫ While this setting will actually cost TPS, Paper's anti-xray is the most efficient in existence! Engine 1 might be less heavy (mainly for clients), but mode 2 is by far more effective.

    Note: Paper users with versions older than 1.12.2 should consider this plugin as an alternative.
    Sᴇʀᴠᴇʀ.Pʀᴏᴘᴇʀᴛɪᴇs
    view-distance
    Def: 10
    Opt: 4-8
    Impact: Heavy

    ➫ This is a big performance setting as it forcibly reduces the max render distance for players. Open world servers (like Survival) should strive to use 6+, but others on shared hosts, low specs, or huge player counts might consider 4-5 if chunk gen causes lag.

    Warning: See note in mob-spawn-range (spigot.yml) if you set your view distance lower than 7.


    network-compression-threshold
    Default: 256
    Optimized: Standalone(512) BungeeCord(-1)
    Impact: Minor

    ➫ This option caps the size of a packet before the server attempts to compress it. Setting it higher can save some resources at the cost of bandwidth, setting it to -1 disables it.

    Note: If your server is in a network with the proxy on localhost or the same datacenter (<2 ms ping), disabling this (-1) will be beneficial.
    Pᴇʀ-Wᴏʀʟᴅ-Sᴇᴛᴛɪɴɢs
    Save precious resources by running/disabling tasks per world! Learn how here (PDF).
    Jᴀᴠᴀ Sᴛᴀʀᴛᴜᴘ Fʟᴀɢs

    The guide below is by a core Spigot/Paper developer and the creator of the timings program. It is applicable to 99% of servers.
    https://mcflags.emc.gs/

    Note: Most shared hosts do not allow changes to flags. Try asking for that feature.
    Pʟᴜɢɪɴs
    Plugins should be a last resort when it comes to performance. Avoid "anti-lag" and mob stacker plugins at all costs! Ironically, these plugins tend to be the laggiest plugin on the server and they throw gameplay mechanics out the window.

    Instead, use plugins that directly optimize tasks or cap resource hogs without compromising gameplay.

    1.14 bug/lag solutions:
    - Fix Pillager Lag (free)
    - Fix Villager Lag (free)

    - Fix Entity Lag (free) (unknown bugs may exist, only recommended for severe entity lag)

    Farm reduction:
    - Mob Manager (paid)
    - Farm Limiter (paid)

    Sᴜᴘᴘᴏʀᴛ
    For assistance outside the parameters of this guide, you are best served posting your issue/question in the Performance Tweaking forum so the entire community can help.

    Dᴏɴᴀᴛᴇ
    Spigot and Paper devs dedicate hundreds of hours to these projects FOR FREE! If their work made your server possible, please consider a donation to the projects.
     

    Attached Files:

    #1 Celebrimbor, Nov 6, 2017
    Last edited: Sep 10, 2019
    • Like x 68
    • Useful x 39
    • Winner x 18
    • Informative x 6
    • Friendly x 6
    • Agree x 4
    • Optimistic x 2
    • Creative x 2
  2. Celebrimbor

    Patron

    Lᴀɢ Tʏᴘᴇs

    TPS - Server Lag

    TPS stands for Ticks Per Second. It is also the only lag type a server owner has direct control over. The guide above is exclusively intended to improve TPS.

    A server processes all tasks at a rate of 20 TPS. Tasks like mob movement, crop growth, and player interactions with blocks need to be ticked by the server to function properly. A TPS below 20 means the server is running behind and must skip tasks in order to keep important tasks on time. Significant TPS loss usually presents itself with minor annoyances like intermittent mob freezing and block break resets. Severe cases could result in server-wide freezes or even crashes.

    TPS Ratings
    20.0 = Flawless - Well done.
    19.95-19.99 = Great - Unnoticeable TPS loss. Most servers live here.
    18.5-19.94 = Fair - Maybe some annoyances, but nothing game-ruining.
    16.0-18.4 = Poor - You definitely need to fix this if this is your average.
    <16.0 = Unplayable...


    Ping - Connection Lag
    Ping (aka latency) reflects how long (in milliseconds) data takes to process and travel between the client and server host. The further a client is geographically separated from the server, the longer this transfer might take. Other common influences on ping are congested or slow connections.

    As a server owner (assuming you have a choice) you should host your server in a region where you prefer to have your player base or one that appeases a broad range of players.

    Example: Eastern US is good for most of the US, CA, and UK, while Central US is more ideal for just US and CA.

    Ping Ratings
    1-90 = Great!
    91-179 = Good - Maybe a slight disadvantage in PvP.
    180-299 = Poor - Regular lag while interacting with blocks/players/entities.
    300-499 = Bad - Nearly unplayable.
    500+ = Assuming your bandwidth is solid, it's time to find a server closer to you.



    FPS - Client Lag
    Do not confuse TPS with FPS (Frames Per Second). FPS reflects a client's ability to process and display what the game/server is wants to render. FPS is 100% client side and has nothing to do with server performance.

    The only thing a server can do to help FPS is cut server features so dinosaur PCs can keep up, but even that is unlikely to make a big difference. Instead of reducing server features, recommend a popular/free client mod called Optifine.

    FPS Ratings
    Note: These rates assume your standing average in a non-graphic-intense location.
    60+ = Perfect - Anything over 60 FPS is overkill for Minecraft. Consider capping FPS below 80 to avoid unnecessary stress on your machine.
    40-59 = Great - Should have no issues.
    25-39 = Good - Occasional rendering lag. Issues if you enter graphic-intense areas.
    15-24 = Poor - Constant rendering glitches. Probably freeze in GI area.
    1-10 = Bad - Client should significantly reduce graphic settings.


    Timing Reports
    Invest time in watching this informative video guide on the Timings program. The video breaks down Timings v1(Spigot) and v2(Paper). The video length is intimidating, but any serious server owner should know how to identity their server's issues.


    If you prefer reading, the Timings guide is explained at length here.
     
    #2 Celebrimbor, Nov 6, 2017
    Last edited: Jul 31, 2019
    • Informative x 17
    • Like x 11
    • Useful x 9
    • Winner x 5
    • Agree x 4
  3. Extremely interesting reading everything here. Well written and useful!
     
    • Agree Agree x 4
    • Like Like x 2
    • Friendly Friendly x 2
  4. For Australia and you cannot get an Aussie VPS/Dedi then West Coast USA.

    For Linode best is fremont

    Code (Text):
    ping -c 5 speedtest.fremont.linode.com
    PING speedtest.fremont.linode.com (50.116.14.9): 56 data bytes
    64 bytes from 50.116.14.9: icmp_seq=0 ttl=56 time=243.9 ms
    64 bytes from 50.116.14.9: icmp_seq=1 ttl=56 time=243.6 ms
    64 bytes from 50.116.14.9: icmp_seq=2 ttl=56 time=243.5 ms
    64 bytes from 50.116.14.9: icmp_seq=3 ttl=56 time=243.3 ms
    64 bytes from 50.116.14.9: icmp_seq=4 ttl=56 time=243.1 ms

    --- speedtest.fremont.linode.com ping statistics ---
    5 packets transmitted, 5 packets received, 0% packet loss
    round-trip min/avg/max = 243.1/243.4/243.9 ms
     
  5. Celebrimbor

    Patron

    Everyone knows that an Australian server with decent player pings is a mythological creature.

    On a serious note, thanks for the input. I am not trying to get too deep into minutia of individual server types/locations or into the dissection of lag variables. The focus is the yml options and the general basics for new server owners. :)
     
  6. Celebrimbor

    Patron

    I appreciate the feedback. I really do obsess over perfection and I wanted to make sure I did this right considering the origins of the idea... this comment was uplifting :)
     
  7. This is fantastic. Thanks for also considering paper users <3 Keep up the great work @Celebrimbor
     
    • Friendly Friendly x 2
  8. electronicboy

    IRC Staff

    Hai, just wanted to clarify a few things;

    regarding autosaving, this isn't entirely async, the writing to the disk is queued, but the actual process of live world -> NBT is sync for reasons of safety, the major difference between autosaving and /save-all is the fact that save-all actually forces all chunks to save, whereas the mechanism in the server that bukkit exposes is incremental, only saving 24 chunks per tick. Spigot modifies this, and no longer limits the number of chunks that can save per tick, but attempts to save all chunks which haven't been saved in so long. Paper has a few patches that brings back the limit (prevents filling the queue up with NBT, which can take a fair amount of memory), and only saves chunks which either have entities or have been modified (as opposed to just modified chunks), and allows you to configure it all per world (do you really need your spawn to save?).

    max-entity-collisions was actually removed from spigot when 1.11 added the maxEntityCramming; Paper has added this patch back and tries to pull the config back from spigot (which as a side effect causes the setting to appear back in spigot.yml, doh)

    with the entity activation range stuff and merging, item despawn isn't a major concern, the impact is situational, of course, there is still some level of evaluation, the server has to check if it's been marked as activated or not. Only on servers where a lot of entities are dropped, e.g. mass PvP servers, should there really be a need to drop this from the default. (This is one of the many overlooked features of the server config...)

    disable-cat-chest-protection this only effects opening chests, the server does not scan for cats sitting ontop of chests every tick, it only does it when you open a chest; as it does a bounding box lookup for the chest itself and the paired chest, which isn't very ideal when you have lots of players running around opening chests.

    min-chunkload-threads is a bit of an iffy one, I would really not advice playing with this unless you determine that you'd actually benefit from this, increasing this value increases the disk load and the cpu load, this all has to go back to the main thread, increasing this setting can actually hurt TPS needlessly.

    pushbased-hoppers is an amazing performance boost, but currently broken in various ways. Fixing this is on my todo list, but it might be a while before I can look at it properly. I would not recommend using this at this current moment in time.

    Updating the paper documentation is on the todo list, however tooling issues and everbody just being crazy busy kinda got in the way.
     
    • Like Like x 1
  9. Celebrimbor

    Patron

    @electronicboy
    Autosaving- Changed some wording, but still trying to keep it simplistic for new owners.

    Collisions- I think I will keep this in there(for now) since it applies to most actively used versions and is still an option(if you use Paper). It's harmless to modify on 1.11+ unless I missed something.

    Activation, merging and despawn- I think I am clear enough that despawn is a desperate change and situational, but activation and merging are a general safe change with almost all positive returns. I will add a note suggesting that owners should only apply the max "optimized" values if they have a notable load from activated/dropped entities.

    Chunk loading- I have left this situational with notes that it only applies to custom/amplified maps because I have done extensive testing on those map types on 3 and 4 threads. 3, while minimal, had a notable improvement for chunk loading. 4 saw no change. My notes are pretty clear that most should leave this alone, but I will stress this more.

    Cat chests- Clarified event to be accurate.

    Hoppers- I added a note to warn against usage. I hope you can fix, this is a biggie...

    Thanks for your input!

    Edit: If you take the time to re-review, please let me know if I missed something well-worth mentioning.
     
    #9 Celebrimbor, Nov 7, 2017
    Last edited: Nov 7, 2017
    • Like Like x 1
  10. @Celebrimbor you're always helping the community out, good on you man. Many people will benefit from this, and @frash23 will never be forgotten.
     
    • Friendly Friendly x 2
  11. Celebrimbor

    Patron

    Thank you for the kind comment. I put a lot of time into this making sure it was done right.

    I remember back in the day benefiting from the original guide(along with hundreds if not thousands of others) and it killed me watching the locked thread slip into the abyss.
     
    • Agree Agree x 2
    • Friendly Friendly x 1
  12. This is great thread.
    I liked this. Thanks for your info for Server-Performance!!!
     
    • Friendly Friendly x 1
  13. Question: This optimize is for 1.12.x or only 1.12.2? Because my server version is 1.12-1.12.1 and 1.12.2 (With ViaVersion).
     
  14. Celebrimbor

    Patron

    This thread is based on the options available in Spigot/Paper 1.12.2. If your server type is Paper 1.12.0, then the only option you will not see is the anti-xray(it was just added recently). If you are on Spigot 1.12.0, then you will also not see the max-entity-collisions option(which is removed on 1.11+). Paper mistakenly forced it back in for 1.11+ servers (oops).

    Keep in mind that basically all these options are available in 1.8-1.12, so it's not specifically optimized for a specific version. Newer versions just might have more tools. :)
     
    • Like Like x 1
  15. Celebrimbor

    Patron

    UPDATE:
    I added a PDF document further explaining the Bukkit.yml spawn-limits numbers...for those that really need to know how it works. Be prepared to do math...

    The PDF is in the original post. Enjoy!
     
    #15 Celebrimbor, Nov 9, 2017
    Last edited: Nov 9, 2017
    • Like Like x 2
    • Winner Winner x 1
  16. How nice of you in frash’s memory!
     
    • Like Like x 1
    • Friendly Friendly x 1
  17. Celebrimbor

    Patron

    It shouldn't be done any other way. Guy was legendary...
     
    • Agree Agree x 1
  18. Agreed. It is very nice of you to do this. :p
     
    • Like Like x 2
  19. Great
     
    • Like Like x 2
  20. @Celebrimbor Thank you for the attached PDF on bukkit spawns! Big help +1
     
    • Like Like x 2
    • Funny Funny x 1