Lag types and how to fix them
What types of lag are there?
A lot of people get mixed-up and confused with lag, the types of lag and how to limit the lag. Overall is split into 3 categories on what is causing the lag. There is one, client lag, two server lag, and 3 latency or internet lag by the less technical name. So what are these different types of lag and how can I limit them?
FPS lag (client lag)
Well what you as a player should be concerned with is primarily the first kind, client lag. This lag is a direct result of the client, and client side computer. This means that this lag is caused by your computer running the minecraft game. Client lag is affected by things like a large amount of entities e.g thousands of dropped blocks or animals and a few other related things such as light values on structures running shader-packs mods etc. This will cause your FPS to drop etc. and is the most common type of lag. When playing on servers this is reduced as the game engine calculations are running on another computer (the server) minimizing the calculations your computer needs to run and therefore giving you as the player more resources to play the game. This is the only kind of lag that is effected by the quality of your computer.
Fixing FPS lag (client lag)
The optifine mod can help you and the players of your server to achieve higher FPS with the same quality. You can also make efforts to limit this by removing all the land in spawn worlds so that it is a void world with only the spawn, or should your spawn reside withing the same world as the world to play in you can use worldedit to fill the caves below with stone to lower the amount of light-values to be calculated when a player spawns. You should also remove any unnecessary and fast flashing redstone and any mobs close by by using world-guard regions and flags to block mob spawning.
TPS lag (server lag)
The next type of lag is server lag. This is described in minecraft as TPS. So what is TPS you may ask. Firstly TPS stands for Ticks Per Second, now before you assume this is redstone ticks it isn’t. It is however in a way related. TPS is otherwise known as game ticks and is a maximum of 20. 20 TPS is hardwired into Minecraft as the universal speed. That is to say the smallest amount of time possible that is distinguishable from the games perspective. Each “Tick” causes the game to recalculate directions of mobs, as well as other things such as growing crops adjusting the direction of mobs etc. It works similar to the absolute figures within our universe such as the planck length (Quantum mechanics defines this length as the smallest possible length. It is calculated at 1.6 × 10-35 meters) absolute zero (defined as the lowest possible energy level) etc. I find it best to compare it to the speed of light; you can’t go faster, you can match it (almost) but you can defiantly go slower. Just to get an idea of how long it is, each redstone tick is equivalent to 2 game ticks. This is incidentally also the reason redstone “half” ticks exist, being 1 game tick. Remember that TPS and FPS are different, on servers they are separated, TPS on the server side controlled by the speed and capabilities of the server and FPS on the players computer on single player TPS and FPS are both affected by your computer this is why as stated above playing on servers increases your FPS usually.
Fixing TPS lag (server lag)
TPS can be improved by lowering the strain on the server. This can be done in a number of different ways. Firstly you can improve the hardware of the server, put more RAM in the system or a beefier CPU, then you can increase the RAM allocation to the minecraft process in your start script and finally in game you can make use of plugins such as ClearLag to clear entities, garbage collect chunks that are loaded and more to optimize your server. I also recommend using the WorldBoarder plugin to limit world sizes and then generate it so that when playing the server does not have to generate chunks. Finally you can also unload unused worlds and clean out your plugins from unused plugins that can be taking resources.
Latency (internet lag)
Finally we get to Latency or Internet lag. Internet lag is usually a result of being geographically far from the server host. This means that the electrical impulses take many milliseconds to reach the server and then have to travel all that way back. This means there can be a lag between input from your computer to it appearing on your and other screens. Take the example of you placing a block in-front of your friend. Firstly you have to click to place the block, that information then has to travel up-to 12,756 km (diameter of earth) to the server. Then this information has to be processed and then sent out to your friends computer to up-to another 12,756 km away. Between this time the data has had to travel up-to 25512 km and this can take a while. Other kinds of internet lag can include bandwidth issues in the event of a DDOS (Distributed Denial Of Service) attack where the server is bombarded with so many connections that it is unable to process your connection, kind of like how roads get slower and blocked with traffic when there is allot of cars. This can slightly be improved by what is know as “the last mile” meaning that if the last mile of cable to where your server is located can increase your ping to longer lag times. If you rent a server it will almost certainly be at a data-center so this cannot be altered and not to worry data centers have excellent fiber optic cables. However on the whole this cannot be improved. You should locate your server geographically near your playerbase or at site that is an internet hub. See internet connectivity maps.
Please also note that you can have combinations of these 3 effects to some degree and this is the cause of the overall lag you and your players experience.