Diagnosing Minecraft Server Lag and Low TPS

How Minecraft works (What causes lag?)

The key to understanding what is causing lag is to understand how Minecraft works. Minecraft server software all operate in a similar matter with one key problem: there is no multi-threading or timing limits for the main game loop. When the server goes to tic, it runs through every TileEntity update, entity update, block update, events and other processes until it's done. This all occurs on one thread, and the next loop cannot start until the current one finishes. The world will not update, players will not appear to move and entities will be frozen in place. Ideally each tic should take no more than 50ms to maintain 20 Tics Per Second (TPS). This can go as low as 55.55ms for 18 TPS with minimal issues. Any lower than this and you will begin to see lag.

Typical causes of lag

There are many things that can cause lag but a few of them will be the most likely culprit for most servers.

  • File usage: Any plugin that is constantly reading from player files, especially on events such as movement, damage or interact. A few examples would be some PVP flags or Glow plugins which will continuously read from player files.
  • Flat files as a database: When you have plugins that use large files to keep track of lots of data iterating through that file or in memory depending on how it is stored will take a long time. Many plugins do this and do not take precautions against how, when the databases become bloated, the processing time will affect the servers tic. You will see this a lot when loading up large MagicSpells configs, or using permissions systems that use YAML instead of a proper database such as PEX and GroupManager.
  • Too many operations: When a plugin spawns too many entities, or attempts to perform complex tasks on events such as movement, you will begin to see lag. Even if each run takes less than 1ms, when you are processing an event 20k times a second it becomes exponential. Plugins that can cause this are world editing plugins such as VoxelSniper and WorldEdit; or protection plugins such as Anti Cheats and World Protections.
  • Too many chunks loaded: One chunk is 16*16*256. This might not sound like a lot but when multiplied out that means there are 65,536 blocks per chunk. Each player can have more than 200 chunks loaded around them, depending on your configuration. Thats upwards of 13,107,200 blocks. This takes up a lot of memory. Also, if even 1% of those are TileEntities that's 131,072 TileEntities loaded that need to update every tic. Mods are notorious for having slow processing times on TileEntities.
  • Cascading WorldGen: This is when a plugin or mod generates structures outside of the chunk it is given. This causes the next chunk to load, generate and then trigger this all over again if it also begins to have structures overflow into the next chunk. This is bad design on behalf of the creators and any plugin or mod doing this should be removed immediately.
  • Tile entities: See LagGoggles section below.

Finding the cause of lag is generally a simple procedure nowadays as most Minecraft server software is built with profiling tools included.

Timings reports for Spigot/PaperSpigot

To get a detailed timings report you can use the follow command.

/timings on

You will want to wait a few minutes and let it lag while your timings are running. After a while, generate the report.

/timings paste

This will give you a link to a website with a nice breakdown of the report with easy options to sift through all the data you are getting. You can learn more on how to read these at Spigot's timing wiki.

You will want to turn timings off afterwards, as you do not want junk data clogging up your next reading, and timings adds additional time to the tic.

/timings off

Timings Reports for Sponge

To get a detailed timings report you can use the follow command.

/sponge timings on

You will want to wait a few minutes and let it lag while your timings are running. After a while, generate the report.

/sponge timings report

This will give you a link to a website with a nice breakdown of the report with easy options to sift through all the data you are getting. Since Sponge's timings system is based off of Spigot's you can learn more on how to read these at Spigot's timing wiki.

You will want to turn timings off afterwards, as you do not want junk data clogging up your next reading, and timings adds additional time to the tic.

/sponge timings off

You can also reset the timings.

/sponge timings reset

Steps to reduce lag

  • Use proper arguments for your script file to launch Minecraft. Learn more about the appropriate Java arguments here
  • Use LuckPerms or a Permissions manager that uses a proper database instead of a flat file
  • Avoid chunk loaders altogether
  • Remove anything that causes cascading world generation
  • Limit Anti Cheat plugins to not be overzealous
  • Limit the view distance of players in server.properties
  • Clear hostile mobs after a set time period
  • Restart the server daily to clean up leaks from Java
  • NEVER reload the server, this causes leaks and other issues
  • Use FastAsync versions of plugins such as WorldEdit and VoxelSniper
  • Limit the size of your world so new chunks are not constantly being created
  • Limit the amount of plugins you use. Not all plugins are built well and the more you have the more issues you are going to encounter

LagGoggles

A big portion of lag on modded servers comes from tile entities. These are the entities created for blocks that are used for processing the block's functionality and events. If these take too long or there are too many it can increase the time per tic bringing down the total server TPS. A way to visualize these problems is to use a mod called LagGoggles. You can download this mod from CurseForce.

Dejar un comentario

ZPanel y Sentora en CentOS 6 x64

ZPanel y Sentora en CentOS 6 x64

ZPanel, un panel de control de alojamiento web popular, se bifurcó en 2014 a un nuevo proyecto llamado Sentora. Aprende a instalar Sentora en tu servidor con este tutorial.

Cómo instalar Vtiger CRM Open Source Edition en CentOS 7

Cómo instalar Vtiger CRM Open Source Edition en CentOS 7

Aprende cómo instalar Vtiger CRM, una aplicación de gestión de relaciones con el cliente, en CentOS 7 para aumentar tus ventas y mejorar el servicio al cliente.

Cómo instalar el servidor Counter-Strike 1.6 en Linux

Cómo instalar el servidor Counter-Strike 1.6 en Linux

Esta guía completa le mostrará cómo configurar un servidor Counter-Strike 1.6 en Linux, optimizando el rendimiento y la seguridad para el mejor juego. Aprende los pasos más recientes aquí.

¿Puede la IA luchar con un número cada vez mayor de ataques de ransomware?

¿Puede la IA luchar con un número cada vez mayor de ataques de ransomware?

Los ataques de ransomware van en aumento, pero ¿puede la IA ayudar a lidiar con el último virus informático? ¿Es la IA la respuesta? Lea aquí, sepa que la IA es una bendición o una perdición

ReactOS: ¿Es este el futuro de Windows?

ReactOS: ¿Es este el futuro de Windows?

ReactOS, un sistema operativo de código abierto y gratuito, está aquí con la última versión. ¿Puede satisfacer las necesidades de los usuarios de Windows de hoy en día y acabar con Microsoft? Averigüemos más sobre este estilo antiguo, pero una experiencia de sistema operativo más nueva.

Manténgase conectado a través de la aplicación de escritorio WhatsApp 24 * 7

Manténgase conectado a través de la aplicación de escritorio WhatsApp 24 * 7

Whatsapp finalmente lanzó la aplicación de escritorio para usuarios de Mac y Windows. Ahora puede acceder a Whatsapp desde Windows o Mac fácilmente. Disponible para Windows 8+ y Mac OS 10.9+

¿Cómo puede la IA llevar la automatización de procesos al siguiente nivel?

¿Cómo puede la IA llevar la automatización de procesos al siguiente nivel?

Lea esto para saber cómo la Inteligencia Artificial se está volviendo popular entre las empresas de pequeña escala y cómo está aumentando las probabilidades de hacerlas crecer y dar ventaja a sus competidores.

La actualización complementaria de macOS Catalina 10.15.4 está causando más problemas que resolver

La actualización complementaria de macOS Catalina 10.15.4 está causando más problemas que resolver

Recientemente, Apple lanzó macOS Catalina 10.15.4, una actualización complementaria para solucionar problemas, pero parece que la actualización está causando más problemas que conducen al bloqueo de las máquinas Mac. Lee este artículo para obtener más información

13 Herramientas comerciales de extracción de datos de Big Data

13 Herramientas comerciales de extracción de datos de Big Data

13 Herramientas comerciales de extracción de datos de Big Data

¿Qué es un sistema de archivos de diario y cómo funciona?

¿Qué es un sistema de archivos de diario y cómo funciona?

Nuestra computadora almacena todos los datos de una manera organizada conocida como sistema de archivos de diario. Es un método eficiente que permite a la computadora buscar y mostrar archivos tan pronto como presiona buscar.