Skip to main content

Minecraft | Minecraft Server Optimization

Overview

Lag is a significant concern for server owners, as it can hinder the smooth operation of their servers. The causes of lag can vary, ranging from resource-intensive server additions to inadequate hardware. However, if you choose to host your server with Hyper Layer, hardware-related issues should not be a concern. Fortunately, there are numerous approaches available to mitigate lag. You can employ plugins designed to reduce lag, upgrade your server's RAM, switch to a more optimized version of Minecraft's executable file (jar), optimize your server's files, and explore other potential solutions. Understanding the root causes of lag is crucial, as it can manifest in different forms such as TPS (ticks per second) lag, latency lag, and FPS (frames per second) lag. In the following discussion, we will delve into each type of lag and outline the most effective methods for optimizing your Minecraft Server.

Types of Lag

Server Lag (TPS)

Server lag, represented by Ticks Per Second (TPS), is a crucial measure of a server's performance. Similar to a heartbeat, a server operates at a fixed rate of 20 ticks per second, with one tick occurring every 0.05 seconds. Each tick progresses various aspects of the server, such as mob movement, grass growth, object displacement, mob behavior updates, and health and hunger updates. The server's TPS serves as the rhythmic pulse that drives its entire functionality. When the TPS is at its peak performance of 20, players experience smooth gameplay without any server-side lag. However, even a slight drop in TPS can result in noticeable lag on the server.

TPS on the server is determined primarily by the speed and capabilities of the hardware used to host it. While the server’s hardware does play an important role in the server TPS, it is not the absolute determinant. Simply throwing the best hardware on a server will not guarantee its performance. What occurs on the server plays an equal role in determining the server’s TPS. Mismanagement of one’s server can be just as detrimental as adequate hardware.

When adding mods or plugins, you should be thinking about the long-term effects of your choices. Many new server owners will mistakenly assume that the number of people on their server will determine the performance of the server. The number of players on the server plays little part in the server’s overall performance. The primary cause of TPS drops is a result of what you have going on in your world. For modded servers, this is more apparent with all the new blocks and the functionality they provide.

For each modded block you add that provides some type of function, the server has to allocate resources to ensure that function is carried out. Now on its own that one block is of little consequence. But if that block forms an array as is typically done with solar panels, then the server will need to dedicate more resources to carry out that array's functions. When we break it down we can get an idea of how much is going on in the background.

If you have an array of 1000 solar panels, each panel when placed is constantly checking the time of day. It then checks the immediate surrounding blocks for cables to deliver power to. If one cable combines with another array, then that mainline is updated with the sum power of both arrays. These updates are happening every 0.05 seconds and when combined with everything else, it all adds up. It’s no surprise the strain it can put on a server that Minecraft wasn’t designed to run.

Client Lag (FPS)

Having low FPS in a game typically results in slow and choppy gameplay, where only a few frames are displayed per second, giving it a slideshow-like appearance. This can make the game feel laggy, which is undesirable. It's important to note that low frame rate on your computer does not necessarily indicate server lag; instead, it suggests that your computer is struggling to keep up with the game. To address this, upgrading the graphics card, RAM, or CPU may be necessary.

It's crucial to understand the distinction between server lag and low FPS. While there are instances where low FPS and server lag occur simultaneously, they are separate issues. Server lag indicates that the server is having difficulty keeping up with the in-game events, while low FPS is a result of your computer hardware being unable to handle the game's demands. Even if the server doesn't have lag, your client may still experience low FPS. For instance, playing on a server with numerous players can lead to both low FPS and lag. The server struggles to process the high activity, resulting in lag, while your computer struggles to display all the characters on the screen simultaneously, causing low FPS.

However, upgrading hardware is not the only solution to address low FPS. In Minecraft, you can optimize performance by adjusting video settings and disabling unnecessary functions. For example, turning off clouds reduces the computational load on your computer. Additionally, closing unnecessary processes and applications frees up system resources for the game. You can quickly do this by closing open programs on your Taskbar and checking the task manager for background processes.

Another approach is to switch to the high-performance power plan in Windows. To do this, navigate to Settings > System > Power and click on "Additional power settings" on the right side. This will open the Power Options section in the Control Panel. If needed, select Show additional - plans, then choose the High performance option.

Connection Lag (Ping)

Connection lag is directly associated with ping, which represents the network latency between the client-side and your Minecraft server. Ping reflects the time it takes for data to process and travel, measured in milliseconds (ms). Lower ping results in smoother gameplay, as lower latency reduces delays. Generally, the farther a server is from your physical location, the higher your latency will be. Choosing a server location near you is the best way to minimize latency.

High latency or ping can lead to lag. If your ping is high, you may experience timeouts and get disconnected from the server, as servers often disconnect clients with excessively high ping. Similarly, client software may also force disconnection due to high ping. Having a high ping is not caused by lag itself, but it contributes to lag and can even cause server instability, potentially leading to crashes.

Several factors can influence ping, including internet connection speed, the quality of your internet service provider, network issues with the Minecraft servers, and firewall configurations. Location plays a significant role in determining ping/latency. For instance, if you are in the United States connecting to a server located in Germany, your ping will be higher compared to someone in Germany playing on the same server.

Latency can vary depending on network conditions and the server's status to which you are connecting. You can assess the expected latency on a server by "pinging" it. This test determines the time taken for the server to receive a message and respond. You can perform a ping test in two ways. Firstly, within the Minecraft client, hover your mouse above the green connection bar on the right side of your server. A number followed by "ms" will be displayed, indicating your ping. Secondly, you can open the command prompt and type "ping ServerIP," replacing "ServerIP" with the actual IP or domain name (e.g., "ping play.hyperlayermc.net"). The test may take a moment to complete, but you should see the average ping displayed.

Detecting lag

Determining the source of lag is not always straightforward. On the client side, you can assess lag by checking your FPS (Frames Per Second). In Minecraft, you can do this by pressing F3, which opens a console displaying game details. If your FPS is consistently low, it indicates client-side lag.

To test for connection lag, you can check your ping to the server. A high ping indicates delays in the connection.

However, neither of these types of lag is directly linked to server performance. To assess server performance, you can check the TPS (Ticks Per Second). If the TPS is low, it indicates that your server is running behind. Identifying the exact cause of low TPS can be challenging, but if you are using Paper and Spigot, you can run a timings report to gain a more detailed breakdown.

Timings Report

As per the latest version(s) of Minecraft 1.20+ spark profiler is the recommended plugin to use for timings reports you can read their documentation here

How to Fix Server Lag

Understanding the art of optimizing your server is crucial for avoiding lag issues. In this guide, we will delve into the necessary adjustments you can make to your server configuration to achieve optimal performance without sacrificing gameplay quality. We will cover all the essential steps involved in server optimization.

One fundamental measure in eliminating lag is pre-generating the world, which should be prioritized above all else. The Chunky plugin is highly recommended for this task. To begin, execute the following commands, which will generate a circular area in the end dimension centered at the spawn point, with a radius of 5000 blocks:

Execute the provided commands to commence the process:

  • chunky world world_the_end
  • chunky shape circle
  • chunky radius 5000
  • chunky start

This will start generating the world for you, make sure to set the radius to something reasonable like 5000 as pre-generation takes a long time.

One option that is beneficial to reduce on any type of Minecraft server is the view distance from the server.properties file. Any number between 4-8 should help with optimizing the server.

If you are running Craftbukkit or Vanilla, you will want to switch to Paper or Spigot. Both of these versions have optimizations for in-game ticks, chunk loading, block decay, and more optimizations for great performance. While both of these versions are great, Paper is recommended as it does not include async chunk loading which improves the server performance immensely.

Files

To achieve optimal server performance, it is essential to make modifications to certain key files such as Bukkit.yml, Paper.yml, and Spigot.yml. The sections below outline the areas within the configuration that should be adjusted, along with recommended changes. Please note that while these suggestions are highly optimized for maximizing server performance, you have the flexibility to make adjustments according to your specific needs.

Before making any modifications to the configuration files, ensure that you completely shut down your server.

Bukkit.yml

spawn-limits:
monsters: 50
animals: 8
water-animals: 3
ambient: 1
chunk-gc:
period-in-ticks: 400
ticks-per:
animal-spawns: 400
monster-spawns: 4

Paper.yml

   max-auto-save-chunks-per-tick: 6
optimize-explosions: false
mob-spawner-tick-rate: 2
disable-chest-cat-detection: true
container-update-tick-rate: 3
max-entity-collisions: 2
grass-spread-tick-rate: 4
despawn-ranges:
soft: 28
hard: 96
hopper:
cooldown-when-full: true
disable-move-event: true
non-player-arrow-despawn-rate: 60
creative-arrow-despawn-rate: 60
prevent-moving-into-unloaded-chunks: true
use-faster-eigencraft-redstone: true
armor-stands-tick: false
per-player-mob-spawns: true
alt-item-despawn-rate:
enabled: true
anti-xray:
enabled: true

Spigot.yml

 save-user-cache-on-stop-only: true
max-tick-time:
tile: 1000
entity: 1000
mob-spawn-range: 6
entity-activation-range:
animals: 16
monsters: 24
raiders: 48
misc: 8
merge-radius:
exp: 4.0
item: 6.0
nerf-spawner-mobs: true

Plugins

Optimizing your server and reducing lag can go beyond modifying core server files. There are several plugins available that specifically target lag reduction. By installing a few of these plugins, you can significantly reduce lag on your server. Here are some recommended lag-reducing plugins:

While these plugins cannot guarantee the complete elimination of lag, they are known to optimize server performance and reduce lag. To install plugins on your Minecraft server, you can refer to the guide provided by our platform.

Helpful Mods

Additionally, there are helpful mods available for Forge servers that can aid in optimization. Unfortunately, there are limited optimization changes that can be made to the configuration files for Forge. However, you can optimize your Forge server by reducing the view distance in the server.properties file. Another approach is to use mods specifically designed to reduce server lag. Here are some recommended mods:

Similar to plugins, the addition of these mods cannot guarantee a lag-free server experience. However, they can contribute to lag reduction and overall improvement. If you are unsure how to add individual mods to your server, you can consult the guide provided by our platform.

Conclusion

As a server owner, it is crucial to prioritize server optimization and aim for a lag-free experience for your players. When players join a server, they expect smooth gameplay without any lag issues. While you may not have control over client-side lag experienced by individual players, there are several steps you can take to optimize your server's performance.

Even if you are running a Vanilla Minecraft server, it is important to note that it can still experience lag. Newer updates like 1.14 have been known to have lag-related issues. To address this, one of the most effective measures is to switch from Vanilla Minecraft to Paper, a server software that offers optimizations specifically designed to reduce lag.

For Forge servers running modded Minecraft, unfortunately, there are limited configuration options available for optimization. However, you can pre-generate worlds using the mods in a single-player environment and reduce the view distance in the server.properties file to improve performance.

Considering the multitude of Minecraft versions and types of lag that can be experienced, it's crucial to understand that as a server owner, you can only directly control server-side lag. By following the guidelines provided in this guide, you can significantly enhance your server's performance and reduce lag issues, leading to a smoother gameplay experience for your players.