Optimization¶
Here you will learn how to optimize your Minecraft server to get better performance.
Credit
Huge credit to this guide by YouHaveTrouble for parts of this guide.
Different kinds of Lag¶
TPS - Server Lag¶
TPS stands for Ticks Per Second. It is also the only lag type a server owner has direct control over.
A server processes all tasks at a rate of 20 TPS. Tasks like mob movement, crop growth, and player interactions with blocks need to be ticked by the server to function properly. A TPS below 20 means the server is running behind and must skip tasks in order to keep important tasks on time. Significant TPS loss usually presents itself with minor annoyances like intermittent mob freezing and block break resets. Severe cases could result in server-wide freezes or even crashes.
TPS Ratings¶
TPS | Rating | Description |
---|---|---|
20.0 | Flawless | Well done. |
19.95 - 19.99 | Great | Unnoticeable TPS loss. Most servers live here. |
18.5 - 19.94 | Fair | Maybe some annoyances, but nothing game-ruining. |
16.0 - 18.4 | Poor | You definitely need to fix it if this is your average. |
< 16.0 | Unplayable... |
Ping - Connection Lag¶
Ping (aka latency) reflects how long (in milliseconds) data takes to process and travel between the client and server 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.
As a server owner (assuming you have a choice) 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.
Attention
As a player, you can't really do anything about your ping. Any program or tool claiming to get you a better ping is probably some malware.
Ping Ratings¶
Ping (ms) | Rating | Description |
---|---|---|
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 | Unplayable... | 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 reflects a client's ability to process and display what the game/server wants 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 client mod called Optifine to players. For newer Minecraft versions, Sodium would also be a good choice.
FPS Ratings¶
Note
These rates assume your standing average in a non-graphic-intense location.
FPS | Rating | Description |
---|---|---|
> 60 | Perfect | Cool! |
40 - 59 | Great | Should have no issues. |
25 - 39 | Good | Occasional rendering lags. Issues if you enter graphic-intense areas. |
15 - 24 | Poor | Constant rendering glitches. Probably freeze in graphic-intense areas. |
0 - 10 | Bad | You should significantly reduce your graphic settings. |
Tip: FPS capping
If you have more FPS than your your monitor can display, consider capping the FPS to a little bit over your monitors refresh rate (Hz) in order to avoid unnecessary stress on your hardware.
Tip: Reduce graphic settings.
In order to get more FPS out of your machine, you should consider reducing your graphic settings. Tinker around with them and try to find the optimal values.
What's lagging? - measuring performance¶
mspt¶
Paper offers a /mspt
command that will tell you how much time the server took to calculate recent ticks. If the first and second value you see are lower than 50, then congratulations! Your server is not lagging! If the third value is over 50 then it means there was at least 1 tick that took longer. That's completely normal and happens from time to time, so don't panic.
timings¶
A great way to see what might be going on when your server is lagging are timings. Timings is a tool that lets you see exactly what tasks are taking the longest. It's the most basic troubleshooting tool and if you ask for help regarding lag you will most likely be asked for your timings.
Using timings¶
- Run
/timings start
to start capturing the timings. - Let your server run normally for a few minutes.
- Run
/timings paste
to stop capturing and open the link provided to view the timings graphically. You can also share this link with people asking for it when you're asking for help regarding lags.
Tip
For more information about timings and how to read them, take a look at the wiki page or this detailed video tutorial by Aikar;
spark¶
Spark is a plugin that allows you to profile your servers CPU and memory usage. You can read on how to use it on its wiki. There's also a guide on how to find the cause of lag spikes here.
Optimizing your server software specific configurations to your needs¶
Every server software has its own set of configurations that you can tweak to suit your specific needs. You probably wont find them as effective as the config of a minigames server in a survival server. You should read every config, understand it and choose if you need to use it or not.
Caution
Bad configurations can ruin the game experience, be especially careful with survival servers. Some values can ruin your mob spawning rates or destroy your players custom redstone circuits.\
It is important for you to understand the configuration changes you are applying to your server. Don't just copy everything from the internet.
Here is a guide made by a well-known member of the community that can help you further in this optimization, it is limited to PaperMC and doesn't have optimized configs for Tuinity, Purpur or any other forks. You can also join this discord, which has an amazing Discord bot that assists you optimizing your server based on your timings report! Remember this is a general suggestion, it may not suit your needs.
Aikars Flags / Startup Flags¶
You should also use correct startup flags, the Aikars flags! Sadly many server hosts won't allow you to edit startup flags by yourself, but they are likely to do it for you if you open a ticket.
World Pre-Generation¶
Another essential step in survival servers is to pre-generate your world, because chunk generation consumes a lot of resources. One of several possible ways is shown below
- Download and install Fast Chunk Pregenerator
- Set your desired world limit.
- Use the command:
/fcp start <radius> [world] [chunkX] [chunkZ]
- Wait for it to finish, it may take a long time and the server will lag while it works. This MUST be done with the server empty / closed to public.
"Too good to be true" plugins¶
Plugins removing ground items¶
Absolutely unnecessary since they can be replaced with merge radius and alt-item-despawn-rate and frankly, they're less configurable than basic server configs. They tend to use more resources scanning and removing items than not removing the items at all.
Mob stacker plugins¶
It's really hard to justify using one. Stacking naturally spawned entities causes more lag than not stacking them at all due to the server constantly trying to spawn more mobs. The only "acceptable" use case is for spawners on servers with a large amount of spawners.
Plugins enabling/disabling other plugins¶
Danger
Anything that enables or disables plugins on runtime is extremely dangerous. Loading a plugin like that can cause fatal errors with tracking data and disabling a plugin can lead to errors due to removing dependency. The /reload
command suffers from exact same issues.