[GUIDE] Server Optimization⚡

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

  1. Celebrimbor

    Patron

    Iɴᴛʀᴏᴅᴜᴄᴛɪᴏɴ
    This is a reboot of the Optimizing Spigot guide by @frash23, a legendary Spigot member we lost in 2017.

    Bukkit, Spigot and Paper have a number of settings that boost efficiency and let you avoid harsh plugins (i.e. ClearLagg). This guide lists recommended values and the pros/cons for applying them.

    Updated for the
    latest release version of Spigot/Paper (1.13.2). This guide will not be fully updated until after 1.14.3 is released. 1.14 - 1.14.2 is NOT recommended for production use and many values have not been re-added. If you made the mistake of updating to 1.14, I strongly urge you to use the latest Paper with its new incremental chunk saving.

    New server owner? Read my
    Lag Guide too.

    PRE-GEN YOUR MAP!
    For open world servers (i.e. Survival), pre-generating your map is the most important step you can take to eliminate lag. Take the time to do it before you even touch your server files.

    1. Get the free plugin WorldBorder
    2. Set a reasonable border distance. You can always expand later.
    3. Command: /wb fill
    4. Wait...this may take a number of hours depending on the map size. This will cause lag, so it's best done before a map is live.
    5. Leave the border in place so players never generate new chunks (cause of lag).

    Bᴜᴋᴋɪᴛ.ʏᴍʟ
    spawn-limits (temporary values for 1.14.0-1.14.2)
    Default: monsters:70, animals:15, water-animals:15, ambient:15
    Optimized: monsters:55(30), animals:12(8), water-animals:5(2), ambient:3(1)
    Performance Impact: Medium

    ➫ While there is more to this than "mobs per player" (learn more in the PDF attached to this thread), lower values result in less spawning. Be cautious setting spawns much lower or mob shortages will be noticeable. Settings later in this guide will make the reduction of spawns less of an impact to gameplay.

    Note: Servers with <10 players average should leave these at default to avoid mob shortages.

    chunk-gc (removed in 1.14+)
    Def: period-in-ticks:600, load-threshold:0
    Opt: period-in-ticks:400, load-threshold:300
    Impact: Minor-Medium

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

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

    ➫ This dictates how often (in ticks) the server will attempt to spawn a monster in a legal location. Doubling the time between attempts helps performance without hurting spawn rates.

    Note: Only go to 3-5 if you have severe TPS loss from the mobSpawn event.

    autosave
    Def: 6000 (usually)
    Opt: 6000
    Impact: Situational

    ➫ This enables Bukkit's world saving function and how often it runs (in ticks). It should be 6000 (5 minutes) by default, just double check it is not 0 (disabled). This is a gradual/queued task and is very efficient. Check out Paper's incremental chunk saving introduced in 1.14.

    Note: If you use Multicraft's autosave in advanced settings, disable it! Multicraft just runs /save-all, which is the map-saving equivalent of cutting butter with a baseball bat.
    Sᴘɪɢᴏᴛ.ʏᴍʟ
    save-user-cache-on-stop-only
    Default: false
    Optimized: true
    Performance Impact: Situational

    ➫ This toggles whether the server constantly saves new user cache data (false) or if it delays that task until a stop/restart (true). This is a huge TPS savings on Spigot (minor on Paper since it's so efficient).

    Note: Whether true or false, 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 setting disables this unstable feature. The minor TPS savings is not worth the potential damage. Why disable? >
    Read here

    view-distance
    Def: 10
    Opt: 4-8
    Impact: Heavy

    ➫ This is a big performance setting, but noticeably impacts gameplay. This caps the chunk render distance for players. Open world servers (like Survival) should strive to use 6-8, but others with low specs, huge player counts, or custom terrain might consider 4-5 if chunk gen causes lag.

    Note: Paper's async chunk loading (and other Paper options) might allow you to keep this in the 7+ range. Paper is that efficient.


    mob-spawn-range
    Def: 8
    Opt: 6 (or same as your "view-distance" if below 6)
    Impact: Minor

    ➫ This sets the max spawning distance (in chunks) from a player. After limiting spawns in Bukkit, this will condense the spawning around your players to mimic the appearance of normal spawn rates. If you did not change those, leave at default.

    entity-activation-range
    Def: animals:32, monsters:32, misc:16
    Opt: animals:24, monsters:24, misc:12
    Impact: Minor

    ➫ This reduces entity ticking as entities outside these ranges will be ticked less often. Lower settings might create the occasional "lazy" mob. Consider leaving these closer to default unless you have issues with active entity ticking.

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

    ➫ Merging items has a huge impact on tick consumption for ground items. Higher values allow more items to be swept into piles and allow you to avoid plugins like ClearLag.

    Note: Merging items will lead to the occasional illusion of items disappearing as they merge together a few blocks away. A minor annoyance.

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

    ➫ When enabled, mobs from spawners will not have AI (will not swim, attack, move). While this is big TPS savings on servers where mob farms are popular, it also has a significant gameplay impact (breaks farms). A merging or farm limiter plugin might be a better solution.

    Note: Paper has an option to force nerfed mobs to jump/swim nonstop. This re-allows water push farms and keeps the TPS savings. They will still not attack/chase players (main cause of lag).

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

    ➫ 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 (i.e. Survival) is critical. Increasing the item merge radius (above) might be enough to avoid this setting change.

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

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

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

    Pᴀᴘᴇʀ.ʏᴍʟ
    Note: Paper has async chunk loading and incremental world saving. If you have chunk-related lag, maybe give Paper a try.

    Warning: Paper is an unofficial fork and is not supported on the Spigot forums. While some consider Paper less stable than Spigot, it significantly enhances performance. If you have issues related to Paper, report them on Paper's issue tracker, not on Spigot!

    max-auto-save-chunks-per-tick (1.14.2 value)
    Default: 24
    Optimized: 6 (large servers should try to use >6 if possible)
    Performance Impact: CRITICAL for 1.14


    ➫ This implements 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.

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

    ➫ Paper applies a custom and far more efficient algorithm for explosions. It has no impact on gameplay.

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

    ➫ This is the delay (in ticks) before an activated spawner attempts to spawn mobs. Doubling the rate to 2 should have no impact on spawn rates. Only go higher if you have severe load from ticking spawners. Keep below 10.

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

    ➫ By default, chests scan for a cat/ocelot on top of it when opened. While this eliminates a vanilla mechanic (cats block chest opening), do you really need this silly mechanic?

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

    ➫ This changes how often your containers/inventories are refreshed while open. Do not go higher than 3.

    fire-physics-event-for-redstone
    Def: true (false in newer builds)
    Opt: false
    Impact: Minor-Medium

    ➫ This stops active redstone from firing BlockPhysicsEvent and can salvage some TPS from a cosmetic task.

    Note: If you have a rare plugin that listens to BlockPhysicsEvent, leave this on.

    max-entity-collisions
    Def: 8
    Opt: 2
    Impact: Minor

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


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

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

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

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

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

    Note: This may slightly increase the disappearance of rendered mobs.

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

    ➫ 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 set true.

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

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

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

    ➫ Like the setting above, but for player-fired arrows that cannot be picked back up (infinity bows & potion-tipped arrows).


    keep-spawn-loaded
    Def: false (true in newer builds)
    Opt: true
    Impact: Medium (situational)


    ➫ This keeps your highest traffic area (spawn) loaded when no players are around and prevents the server from having to constantly load the same region.

    Note: Be sure to set keep-spawn-loaded-range to a chunk range that makes sense for your spawn. Your spigot.yml view-distance will be used if not set.

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


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

    Note: If you did not pregenerate your world (what's wrong with you?!), this setting might be a godsend.

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


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

    Note: If you use the plugin Pandawire, you might consider this option instead as Pandawire knowingly breaks some redstone machines.

    anti-xray.enabled
    Def: false
    Opt: true, engine-mode: 2
    Impact: N/A

    ➫ While this setting will actually cost TPS, it is the most efficient anti-xray in existence! Engine-mode 1 might be less heavy, but mode 2 is by far the more effective engine at preventing cheaters.

    Note: Paper users with versions older than 1.12.2 should consider this plugin as an alternative.
    Sᴇʀᴠᴇʀ.Pʀᴏᴘᴇʀᴛɪᴇs
    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 more 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.
    Jᴀᴠᴀ Sᴛᴀʀᴛᴜᴘ Fʟᴀɢs

    The guide linked below is actively researched and updated by a Spigot/Paper developer and is recommended for 99% of servers.
    https://mcflags.emc.gs/

    Note: Most shared hosts have preset flags and do not allow changes. Do not worry about these settings if that's you.

    Sᴜᴘᴘᴏʀᴛ
    For performance assistance outside the parameters of this guide, you are best served by posting your issue/question in the Spigot Performance Tweaking forum so the entire Spigot community has a chance to address your needs.

    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 both projects.
     

    Attached Files:

    #1 Celebrimbor, Nov 6, 2017
    Last edited: Jun 12, 2019 at 3:53 PM
    • Like x 43
    • Useful x 24
    • Winner x 12
    • Agree x 4
    • Informative x 4
    • Friendly x 4
    • Optimistic 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 Performance Guide above is exclusively intended to improve TPS.

    Server performance is based on 20 ticks each second. Each "tick" causes the server to calculate tasks like mob movement, crop growth, and processing player interactions. A TPS below 20 means the server is running behind and must skip tasks in order to keep important tasks on time. Severe cases of TPS loss include player and mob setbacks or even server-wide freezes and crashes.

    Tick Rates
    20.0 = Flawless - Well done.
    19.95-19.99 = Great - Unnoticeable TPS loss. Most lag-free servers live here.
    18.5-19.94 = Fair - Maybe some minor hiccups but nothing game-ruining.
    17.0-18.4 = Poor - You definitely need to fix this.
    <17.0 = Unplayable...


    Ping - Connection Lag
    Ping (aka latency) reflects how long (in milliseconds) data takes to process and travel between the client and 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. For example, too many devices streaming HD video while you're playing.

    As a server owner, 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. For example, Eastern United States is good for most of the US, CA, and UK.

    Ping Rates
    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 directly reflects a client's ability to process and display what the game/server is asking it 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 Rates
    60+ = Perfect - Anything over 60 FPS is overkill for Minecraft. Consider capping FPS below 100 to avoid unnecessary stress on your machine.
    40-59 = Great - You should not have issues.
    21-39 = Good - Occasional rendering glitches.
    11-20 = Poor - Constant rendering glitches.
    1-10 = Bad - Client should use Optifine, reduce particles, and set render distance <6.


    Timing Reports
    Invest time watching this informative video guide on the Timings program, made by its creator. 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: Mar 11, 2019
    • Informative x 12
    • Like x 7
    • Useful x 5
    • Agree x 3
    • Winner x 3
  3. Extremely interesting reading everything here. Well written and useful!
     
    • Like Like x 1
    • Friendly Friendly x 1
  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
  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

Share This Page