Home of The Tech Fortress Servers

Wednesday, September 7, 2016

Understanding and Mitigating Network Connection Lag

+
Lately there's been reports related to network lag. While this is naturally due to the player's internet connection, I've lately discovered that there are ways to alleviate this type of lag.

Since this is the first of potentially many more posts on lag, it would probably be best to quickly outline the common types of lag. (Yes, there is more than one type of "lag.") Using a diagram is probably the easiest way to depict this:

As depicted above, server lag (which you can monitor via /lag) is only one of many "types of lag;" other  areas that can lag include the server's connection to the internet, the "internet" itself, the player's connection to the internet, and the player's computer. The player is often referred to as the "client."

To better illustrate this concept, let's use the example of a cow moving towards water. First, the server  calculates the instruction of where the cow goes (server hardware). This is then sent out to the player (internet connection). Finally, the player's computer receives the server's instructions for the cow, and makes the cow move on the screen.

If the player's connection was laggy, the player won't know the cow has moved because his computer hasn't yet received the instructions. This doesn't mean the server is lagging (as the instructions have been made and were sent), but rather the player's computer hasn't received the instructions yet.

Now that we have discussed connection lag, you may be wondering if there's any way to fix this issue, other than getting a better internet connection. And the answer is yes, there are ways to help reduce the problem!

Remember our example with the cow? Well, now let's assume there's 1000 cows. That's 1000 sets of instructions being sent to the client about where each cow is going. As you can imagine, more connection bandwidth is being used to send 1000 instructions all at once. Therefore, we can conclude that as more cows are near a player, the player uses more of the connection to receive instructions about each cows' movement. Even though the server may be able to handle generating instructions for a 1000 cows, your connection may not have enough bandwidth to handle all those instructions for each cow; I experienced this personally, seeing my ping drop and more of my connection bandwidth used when I visited a player's cow farm.

Thus, you can probably determine that being around less animals and monsters (such as cows) will help reduce connection lag issues. Designing efficient farms that don't hold a ton of animals/monsters at one time (such as a mob grinder that quickly kills mobs) or building a dock for boats instead of leaving a bunch lying around would make things a lot easier for your connection to handle, for instance. Efficient redstone designs that use less gates or devices (repeaters, comparators, etc.) would also help, since the server sends you the state of each and every device's state (as well as making your redstone contraptions operate far faster!)

Hopefully this post has given you a good overview on "network lag," and some ideas on how to make it less of an issue while playing on Tech Fortress, or any other server for that matter. Leave a comment if you have any ideas of your own that you'd like to share, or if you have a question on anything discussed here. Hope you have a less laggier day!