Minecraft Server Optimization
Last modified on Jun 9, 2022 in Control Panel
One of the biggest concerns for server owners is lag. Lag can have a variety of causes, whether it’s from resources you add to your server or the hardware your server runs on. Luckily, if you host with Apex, hardware should not be an issue.
There are many ways that you can reduce lag on your server.
You can get plugins that can help reduce lag, you can upgrade your server ram, switch your jar to a more optimized version of Minecraft, optimize your files, and much more.
With all of these options, you may be wondering what causes lag and what you should do to get rid of it. There are a few different types of lag that can occur such as TPS, Latency, and FPS lag. In this guide, we will give a breakdown of the different types of lag and the best way to mitigate it on your Minecraft Server.
Types of Lag
Server Lag (TPS)
Overall server performance is represented by its TPS (Ticks Per Second). A server’s TPS is like a heartbeat. Your server beats at a fixed rate of 20 ticks per second, so one tick every 0.05 seconds.
On each tick, various aspects of the server advance a little bit; Mobs move, grass grows, animals spawn, almost everything that happens on the server relies on ticks. When at peak performance, 20 TPS, you’ll experience normal gameplay without any server-side lag. But if your server’s TPS starts to drop, you’ll begin to notice lag while you play.
What occurs on the server, as well as the hardware it is running on, plays an important role in determining the server’s TPS. Mismanaging the server can be just as detrimental as inadequate 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 be the only thing that determines their performance. The number of players on the server can have an effect, but this is relatively small compared to the impact of redstone machines, mob farms, and mods/plugins. The primary cause of TPS drops is a result of what you have going on in your world at a given time.
Client Lag (FPS)
Having low FPS will generally come with your game behaving slowly. If your frame rate is low enough, playing the game may feel like watching a slideshow. Having a low frame rate on your server does not mean that the server is lagging but that your computer is failing to keep up with the game. If you do have a consistent low frame rate on your PC, you will most likely need to adjust your game settings, update your drivers, or upgrade the graphics card, RAM, or CPU.
It is very important that you know that there is a difference between server lag and low FPS. There are times that low FPS and server lag can appear at the same time, you may think that the FPS is due to the server having lag, but it is often a separate issue with the device you are running the game on.
There are a lot of ways to fix low FPS without having to upgrade your hardware. In Minecraft, you can go to the video settings and reduce all of the functions. For example, you can turn clouds off so that your computer doesn’t have to try and render them. It’s also a good idea to close other processes running in the background that you don’t need. This frees up resources that your computer can dedicate to the game. You can do this quickly by closing anything that’s open on your Taskbar.
Another option is to switch to the high-performance plan in your device’s power options. If you are on a Windows PC, you can do this by pressing the Windows Key + X to open a new context menu. Then choose “Power Options” to open up your settings. Change the Power Mode to “Best Performance”.
Connection Lag (Ping)
Connection lag correlates with your ping. Ping refers to the network latency between your game and your server. This reflects how long in milliseconds data takes to process and travel. If you have high ping, it’s possible that your connection to the server may timeout. Having high ping is not something that’s due to lag, but it causes lag. It may also crash the game because of the instability.
Having a low ping is best as lower latency provides smoother gameplay. Typically, the further away a server is from your physical location, the greater your ping will be. The best way to minimize this is to move your server to the location closest to you and your players. Some factors that might affect ping include Internet connection speed, the quality of a user’s Internet service provider, issues with the Minecraft servers network, and the configuration of firewalls.
Latency can change depending on network conditions and the status of the server to which you’re connecting. You can test how bad latency will be on a server by “pinging” the server. This determines how long it takes for the server to receive a message and respond. There are a few ways to test your ping, we recommend using your command prompt. Open a terminal or command prompt (you can do this with Windows+X too), then type “ping ServerIP”. For example:
“ping play.apexmc.co”. The process may take a second to run, but you should see the average ping displayed once it is done.
Creating a timings report
A timings report allows you to monitor how long it takes for your server to process an event. This allows you to see where lag issues may arise and cause the server TPS to drop. To run a timings report join your server and run the command
/timings on and after ~30 minutes, run the command
/timings paste. This will provide you with a link, go ahead and click on it to open the report in your browser.
Reading a timings report
The top section of the timings report will have a simple graph that shows your server’s average TPS over time in five-minute intervals. To the left of the graph is a brief summary of the server, including the average TPS. These are a nice way to get an idea of your server’s performance at a glance, but they won’t tell you why your server is lagging. To diagnose the cause of lag you will want to focus on the data in the section beneath the graph.
The lower section of a timings report is a complete breakdown, also called a ‘tree view’, of every tick that occurred while the report was running. Each tree starts as a broad overview of what type of tick is happening. The top tree in the list will often be a complete summary of the entire server’s average ticks. You can click on these trees to expand them and get more detailed information with each layer. As you reach the end of the series of layers, you will be able to see what specific block or entity is ticking, and how long it is taking to tick.
By default, a timings report will sort information so that processes that take the longest to tick appear first. These items are often the cause of any lag you may be experiencing on the server. Going through the top trees on the list is the quickest way to identify the cause of your lag. Once you know the cause, you can go back to your server and remove it, or edit your settings to reduce the impact it has.
Reading a timings report can be a little intimidating at first. If you get stuck or if you are not sure you are reading it right, you have some really good resources to help clear up any confusion. Your best option would be to contact our support team. All of our tech support agents are familiar with timings reports and can analyze them for you, or walk you through how to read a report if you are getting stuck.
How to fix server lag
Knowing how to optimize your server is vital in preventing server lag. Luckily, there are a lot of tools available for you to use to get the best possible performance out of your server and even push it beyond its normal performance limits.
Removing Tick/Lag machines
Redstone is a wonderful mechanic to create almost any kind of machine. However, having too many machines will cause problems to arise. It’ll decrease your TPS, and cause lag for all players. The solution for this is to limit the machines and install anti-redstone-lag plugins like this one. Otherwise, try not to have too many automated farms, mob grinders, or anything else that would involve complex redstone mechanics. Whenever possible you should also include a method to turn off your machines and farms so they are not running all the time and eating up your server’s resources.
Pre-generating your world
A vital step in lag removal is pregenerating the world. This should be done before anything else. The best way to do this is with the Chunky plugin. All you have to do is install the plugin and run the following commands:
/chunky radius 5000 followed by
This will pre-generate a 5,000 block radius around your world spawn. The server will lag heavily while the process is running, but once it is done your performance will improve dramatically. You can increase the radius as much as you like, but we recommend keeping it under 20,000 blocks. Any larger and you could possibly create more lag than you would be preventing.
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 6-8 should help with optimizing the server without being detrimental to gameplay. While changing the view distance, it is also recommended to change the “Net Compression Threshold” to 64, and the “Max Tick Time” to -1 to further improve overall performance.
Optimizing your config files
Some of the main files that you will want to modify to really optimize your server are Bukkit.yml, Paper.yml, and Spigot.yml. Below we have included which settings you will want to change to get the best performance possible with minimal effect on your gameplay.
To use these settings, stop your server from your control panel then click on the tabs below to show the optimized settings for each file. These files can be found in the FTP File Access tab of your control panel. You can open them in the online web editor by clicking on the “edit” button to the far right of the file. Once you are done editing be sure to click the green “Save” button, then restart the server for the changes to take effect.
spawn-limits: monsters: 50 animals: 8 water-animals: 7 water-ambient: 10 water-underground-creature: 5 ambient: 1 chunk-gc: period-in-ticks: 400 ticks-per: animal-spawns: 400 monster-spawns: 5 water-spawns: 11 water-ambient-spawns: 21 water-underground-creature-spawns: 11 ambient-spawns: 31 autosave: 6000
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 water: 16 villagers: 24 flying-monsters: 24 merge-radius: exp: 4.0 item: 6.0 tick-inactive-villagers: false nerf-spawner-mobs: true arrow-despawn-rate: 300 trident-despawn-rate: 300
max-auto-save-chunks-per-tick: 6 optimize-explosions: true mob-spawner-tick-rate: 3 disable-chest-cat-detection: true container-update-tick-rate: 3 max-entity-collisions: 2 grass-spread-tick-rate: 4 despawn-ranges (in 1.18+, use this setting for all 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 items: COBBLESTONE: 300 NETHERRACK: 300 SAND: 300 DIRT: 300 GRAVEL: 300 anti-xray: enabled: false engine-mode: 2
Changing the base server files is not the only way to reduce or get rid of lag. There are many plugins available created for the sole purpose of reducing lag. If you know which ones to use, you can find that lag can be reduced significantly on your server after installing a plugin or two. Here is a list of the plugins we recommend most often to our users.
Limit Pillagers (1.14+)
Village Optimiser (1.14.2+)
MergedMobs (Premium, 1.7+)
Entity Tracker Fixer (1.14+)
Farm Limiter (Premium, 1.7+)
Mob Farm Manager (Premium, 1.7+)
Lag Assist (Premium 1.8+)
Armor Stand-Limiter (1.8+)
These plugins are not guaranteed to completely stop the lag on your server, but they can go a long way to help. If you do not know how to install plugins on your Minecraft server, We have an easy guide for you to follow.
One of the most important aspects of owning a server is making sure it is well optimized and lag-free. When players join a server, they don’t expect to have issues with lag. You cannot always control the lag they experience client-side, but there is plenty you can do to prevent server-sided lag.
If you are running a Vanilla Minecraft server, you may think that it won’t experience lag. It is the base version of the game after all. Unfortunately, the base game doesn’t offer a lot of options for optimization and can be really laggy as a result. Newer updates such as 1.17+ have made the game a lot more resource-hungry. Switching to Paper or one of its forks like Purpur or Airplane will drastically improve your performance. Following this guide after switching to Paper will further improve performance, keep your players happy, and keep your server lag-free.