Optimizing your server

1. Use Paper

  • Paper is a high-performance fork of Spigot that adds extra features while also increasing server performance. You can find more information about it here.

  • Paper also tends to fix bugs that come out after initial releases of Spigot for the latest versions of Minecraft. A good example would be the 0-tick farm bug that existed for a long time, and for the people who didn't want 0-tick farms in specific to be patched, they added it as an option in the paper.yml config!

  • Paper has better API support for plugin developers, which means it has more support for plugin creators and more features that can be utilized in their plugins.

  • Another reason to get Paper is thanks to their asynchronous chunk loading and generation. This means fast traveling methods won't lag your server as hard and chunk loading becomes much faster in general!

2. Customize your server configurations

Now we will start with getting the server optimized manually. It's relatively easy to learn! We will start by configuring server.properties - Keep in mind that this guide only covers certain options, it's encouraged to take a look at everything and customize it to your liking!

server.properties

broadcast-rcon-to-ops=true
view-distance=8
max-build-height=256
server-ip=0.0.0.0
rcon.port=25575
level-seed=
allow-nether=true
gamemode=survival
enable-command-block=true
server-port=25565
enable-rcon=false
server-name=ExampleName
enable-query=false
op-permission-level=5
prevent-proxy-connections=false
generator-settings=
resource-pack=
player-idle-timeout=0
level-name=world
rcon.password=
motd=Example Server Message of the Day
query.port=25565
force-gamemode=false
debug=false
hardcore=false
white-list=false
broadcast-console-to-ops=true
pvp=true
spawn-npcs=true
spawn-animals=true
generate-structures=true
snooper-enabled=true
difficulty=hard
function-permission-level=2
network-compression-threshold=256
level-type=default
max-tick-time=60000
spawn-monsters=true
enforce-whitelist=false
max-players=100
use-native-transport=true
spawn-protection=0
resource-pack-sha1=
online-mode=true
allow-flight=false
max-world-size=29999984

There are a lot of settings here, but we will only focus on the ones that matter the most for what type of server you plan on running.

view-distance is how far chunks will be loaded by players in your server. You will want this between 4 and 16, in multiples of two (I.E. 4, 6, 8, 10, 12, 14, 16). Too little and you won't be to see very far, too much and the server will have performance issues. This generally depends on how many players you plan on having in your server, and how much RAM you have.

  • View distances 12 - 16 would be best for around one to five players. Like a small group of friends, or a very small server.

  • View distances 8 - 10 are generally best for average sized servers (around ten or more players), although view-distance is set to 8 by default. It's usually best to keep view-distance set to 8.

  • View distances 4 and 6 are best for very small worlds, like minigames. This way you can have a lot of players in the same general area, without taking up too many server resources.

level-seed is what you'll want to set when using a custom seed for your server's world, keep in mind that you'll need to generate a new world in order for this setting to work.

motd is the text that shows up for your server in the in-game server list. You can make a custom MOTD with colors and formatting here.

difficulty can be set to peaceful, easy, normal, or hard. Keep in mind that hard is best if you plan on having villager farms, as any other difficulty gives a chance for villagers to permanently die, rather than be converted into zombie villagers.

max-players can be set to anything, like 9001, or 1337, or simply 100. This option is up to you, although it's best to set it according to how many players you expect to have.

spigot.yml

config-version: 12
settings:
  log-villager-deaths: false
  debug: false
  sample-count: 12
  player-shuffle: 0
  user-cache-size: 1000
  int-cache-limit: 1024
  late-bind: false
  item-dirty-ticks: 20
  bungeecord: false
  attribute:
    maxHealth:
      max: 2048.0
    movementSpeed:
      max: 2048.0
    attackDamage:
      max: 2048.0
  netty-threads: 4
  timeout-time: 60
  restart-on-crash: false
  restart-script: ./start.sh
  filter-creative-items: true
  moved-wrongly-threshold: 10
  moved-too-quickly-multiplier: 10
  save-user-cache-on-stop-only: false
commands:
  send-namespaced: true
  spam-exclusions:
  - /skill
  replace-commands:
  - setblock
  - summon
  - testforblock
  - tellraw
  log: true
  silent-commandblock-console: false
  tab-complete: 0
messages:
  restart: The server is restarting.
  whitelist: You are not whitelisted.
  unknown-command: Unknown command. Type "/help" for help.
  server-full: The server is full!
  outdated-client: Outdated client! Use version {0}
  outdated-server: Outdated server! Currently using {0}
stats:
  disable-saving: false
  forced-stats: {}
advancements:
  disable-saving: false
  disabled:
  - minecraft:story/disabled
world-settings:
  default:
    seed-endcity:
    trident-despawn-rate: 900
    view-distance: default
    max-entity-collisions: 8
    seed-desert:
    seed-igloo:
    seed-jungle:
    seed-swamp:
    seed-shipwreck:
    seed-ocean:
    seed-outpost:
    verbose: false
    item-despawn-rate: 24000
    merge-radius:
      item: 0
      exp: 0
    arrow-despawn-rate: 600
    enable-zombie-pigmen-portal-spawns: true
    wither-spawn-sound-radius: 0
    hanging-tick-frequency: 100
    entity-activation-range:
      villagers: 32
      flying-monsters: 32
      villagers-work-immunity-after: 100
      villagers-work-immunity-for: 20
      villagers-active-for-panic: true
      water: 16
      raiders: 48
      animals: 32
      monsters: 32
      misc: 16
      tick-inactive-villagers: true
      wake-up-inactive:
        animals-max-per-tick: 4
        animals-every: 1200
        animals-for: 100
        monsters-max-per-tick: 8
        monsters-every: 400
        monsters-for: 100
        villagers-max-per-tick: 4
        villagers-every: 600
        villagers-for: 100
        flying-monsters-max-per-tick: 8
        flying-monsters-every: 200
        flying-monsters-for: 100
    random-light-updates: false
    growth:
      bamboo-modifier: 100
      sweetberry-modifier: 100
      kelp-modifier: 100
      beetroot-modifier: 100
      carrot-modifier: 100
      potato-modifier: 100
      cactus-modifier: 100
      cane-modifier: 100
      melon-modifier: 100
      mushroom-modifier: 100
      pumpkin-modifier: 100
      sapling-modifier: 100
      wheat-modifier: 100
      netherwart-modifier: 100
      vine-modifier: 100
      cocoa-modifier: 100
    mob-spawn-range: 4
    ticks-per:
      hopper-transfer: 8
      hopper-check: 1
    hopper-amount: 1
    entity-tracking-range:
      players: 48
      animals: 48
      monsters: 48
      misc: 32
      other: 64
    save-structure-info: true
    max-tnt-per-tick: 250
    squid-spawn-range:
      min: 45.0
    hunger:
      jump-walk-exhaustion: 0.05
      jump-sprint-exhaustion: 0.1
      combat-exhaustion: 0.1
      regen-exhaustion: 2.5
      swim-multiplier: 0.02
      sprint-multiplier: 0.05
      other-multiplier: 0.0
    max-tick-time:
      tile: 50
      entity: 50
    seed-village:
    seed-feature:
    seed-monument:
    seed-slime:
    dragon-death-sound-radius: 0
    nerf-spawner-mobs: false
    zombie-aggressive-towards-villager: true
  worldeditregentempworld:
    verbose: false

Most stuff in spigot.yml are things you won't want to touch, but a few things that are useful are what's listed below. Listed here is a page explaining most of everything in spigot.yml

There are a few interesting things you can change, a few of them being:

  • merge-radius is the amount of space before dropped items (blocks, mob drops, etc.) will merge. Set these to 0.0 for a classic back-in-the-day Minecraft feel!

  • growth contains settings for growth modifiers for many different types of crops, you can change these individually to whatever values you like!

  • ticks-per and hopper-amount are great if your server contains mass autofarms with thousands of hoppers, boosting hopper speed and/or amount can help reduce the amount of lag your server gets. There is no need to change this if your server doesn't have these, but the effect is definitely noticeable.

paper.yml

verbose: false
config-version: 20
settings:
  chunk-tasks-per-tick: 1000
  enable-player-collisions: true
  save-empty-scoreboard-teams: false
  suggest-player-names-when-null-tab-completions: true
  region-file-cache-size: 256
  incoming-packet-spam-threshold: 300
  use-alternative-luck-formula: false
  use-versioned-world: false
  bungee-online-mode: true
  save-player-data: true
  load-permissions-yml-before-plugins: true
  watchdog:
    early-warning-every: 5000
    early-warning-delay: 10000
  velocity-support:
    enabled: false
    online-mode: false
    secret: ''
  spam-limiter:
    tab-spam-increment: 1
    tab-spam-limit: 500
  book-size:
    page-max: 2560
    total-multiplier: 0.98
  async-chunks:
    enable: true
    threads: -1
timings:
  enabled: true
  verbose: true
  server-name-privacy: false
  hidden-config-entries:
  - database
  - settings.bungeecord-addresses
  - settings.velocity-support.secret
  history-interval: 300
  history-length: 3600
  server-name: ExampleServerName
messages:
  no-permission: '&4You do not have permission to perform this command.'
  kick:
    authentication-servers-down: ''
    flying-player: Flying is not allowed on this server.
    flying-vehicle: Flying is not allowed on this server.
    connection-throttle: Connection throttled! Please wait before reconnecting.
world-settings:
  default:
    light-queue-size: 20
    zombie-villager-infection-chance: -1.0
    iron-golems-can-spawn-in-air: false
    phantoms-do-not-spawn-on-creative-players: true
    phantoms-only-attack-insomniacs: true
    seed-based-feature-search: true
    portal-create-radius: 16
    fix-zero-tick-instant-grow-farms: false
    entities-target-with-follow-range: false
    per-player-mob-spawns: false
    keep-spawn-loaded-range: 8
    keep-spawn-loaded: true
    auto-save-interval: -1
    armor-stands-do-collision-entity-lookups: true
    disable-ice-and-snow: false
    skeleton-horse-thunder-spawn-chance: 0.01
    count-all-mobs-for-spawning: false
    disable-thunder: false
    nether-ceiling-void-damage-height: 0
    allow-non-player-entities-on-scoreboards: false
    disable-explosion-knockback: false
    water-over-lava-flow-speed: 5
    use-faster-eigencraft-redstone: true
    parrots-are-unaffected-by-player-movement: true
    container-update-tick-rate: 1
    non-player-arrow-despawn-rate: -1
    creative-arrow-despawn-rate: -1
    prevent-tnt-from-moving-in-water: false
    grass-spread-tick-rate: 1
    bed-search-radius: 3
    armor-stands-tick: false
    spawner-nerfed-mobs-should-jump: false
    allow-leashing-undead-horse: false
    baby-zombie-movement-speed: 0.5
    all-chunks-are-slime-chunks: false
    mob-spawner-tick-rate: 1
    disable-teleportation-suffocation-check: false
    optimize-explosions: false
    portal-search-radius: 128
    fixed-chunk-inhabited-time: -1
    enable-treasure-maps: true
    treasure-maps-return-already-discovered: false
    prevent-moving-into-unloaded-chunks: false
    use-vanilla-world-scoreboard-name-coloring: false
    max-auto-save-chunks-per-tick: 24
    filter-nbt-data-from-spawn-eggs-and-related: true
    max-entity-collisions: 8
    disable-creeper-lingering-effect: false
    duplicate-uuid-resolver: saferegen
    duplicate-uuid-saferegen-delete-range: 32
    remove-corrupt-tile-entities: false
    experience-merge-max-value: -1
    falling-block-height-nerf: 0
    tnt-entity-height-nerf: 0
    anti-xray:
      enabled: true
      engine-mode: 1
      chunk-edge-mode: 2
      max-chunk-section-index: 3
      update-radius: 2
      hidden-blocks:
      - gold_ore
      - iron_ore
      - coal_ore
      - lapis_ore
      - mossy_cobblestone
      - obsidian
      - chest
      - diamond_ore
      - emerald_ore
      - ender_chest
      replacement-blocks:
      - stone
    game-mechanics:
      nerf-pigmen-from-nether-portals: false
      disable-pillager-patrols: false
      disable-sprint-interruption-on-attack: false
      disable-relative-projectile-velocity: false
      shield-blocking-delay: 1
      disable-chest-cat-detection: true
      disable-player-crits: false
      disable-end-credits: true
      disable-unloaded-chunk-enderpearl-exploit: true
      scan-for-legacy-ender-dragon: true
      pillager-patrols:
        spawn-chance: 0.2
        spawn-delay:
          per-player: false
          ticks: 12000
        start:
          per-player: false
          day: 5
    squid-spawn-height:
      maximum: 0.0
    max-growth-height:
      cactus: 3
      reeds: 3
    lightning-strike-distance-limit:
      sound: -1
      impact-sound: -1
      flash: -1
    hopper:
      cooldown-when-full: true
      disable-move-event: false
    lootables:
      auto-replenish: false
      restrict-player-reloot: false
      reset-seed-on-fill: true
      max-refills: -1
      refresh-min: 12h
      refresh-max: 2d
    fishing-time-range:
      MinimumTicks: 100
      MaximumTicks: 500
    despawn-ranges:
      soft: 32
      hard: 128
    frosted-ice:
      enabled: true
      delay:
        min: 20
        max: 40
    alt-item-despawn-rate:
      enabled: false
      items:
        COBBLESTONE: 300
    generator-settings:
      flat-bedrock: false
    baby-zombie-movement-modifier: 0.5
    viewdistances:
      no-tick-view-distance: -1

There are a lot of useful settings in here, feel free to check them out for yourself! Also make sure to customize plugins to your liking, as having everything utilized makes a server shine!

3. Lag management

If your server starts to lag, take a look at your plugins, make sure none of them are known to cause issues or have incompatibilities with your current version. Another very useful feature of Paper is timings. Doing /timings report in-game will generate a report that tells you what may be causing unneeded TPS (ticks-per-second) usage on your server. 20 TPS is perfect, 0 lag on your server. Anything less than that means something may be causing lag.

Also, contrary to popular belief, most "Clear Lag" plugins will not actually reduce lag by getting rid of dropped items. It's up to server owners to optimize and properly manage their server for lag not to happen. Dropped items generally do not cause TPS lag, but rather FPS (framerate) lag if there's too many of them.

Good examples of things that cause TPS lag are players loading new chunks, players traveling fast (elytra, boosted minecart, flying, etc.) mass autofarms, lag machines, noise machines, condensed mob farms, egg farms with too many chickens (too many mobs in one space, leading to TPS lag due to mob collisions and the chickens trying to pathfind), and things with many moving parts involving pistons, like large flying machines.

Bad examples of things that actually don't cause TPS lag but may be confused for it are things like many dropped items on the ground causing loss in framerate, minecarts, armor stands, and item frames causing framrate lag due to the amount of entities being rendered, fishing bobbers and boats, which some "lag clearing" plugins remove for some reason, arrows, and other things like that.

Last updated