Disclaimer: I am answering this post with multiplayer in mind. This is only applicable when your server is located somewhere in the internet.
This post may be TL;DR for some people. In which case, skip to The Workaround section.
More bandwidth is not enough.
Connection with low latency is not enough.
Why? let me explain...
When Mojang updated Minecraft to 1.3, the single player became a multiplayer game, thus unifying the client and the server. It's both a good thing and bad thing.
The good thing is that bugs that are specific to multiplayer and single player are significantly minimized. Mods also became universal: no need to download separate packages for the client and server. Multiplayer-compatible mods became the norm.
But it all came with a cost.
When our private server upgraded from 1.2.5 to 1.4.x back in December, we noticed that some of our users who used to not get any lag had a bad experience. At first, we dismissed it as a connection problem on their side (after all, our ISP here is known for bad service on certain areas).
By March, all of us were experiencing significant lag, even if there was only 1 person on the server. That prompted us to track down the problem. Based on our observations, here's what we found out:
- On multiplayer, the Client and Server sends a lot of packets to each other. Much more than what it used to be before the 1.3 update. On an area without any machines running, you can have 40-50 packets/sec for incoming and outgoing traffic. On a busy area, you could have 70-100 packets/sec. This is an indication that there is a lot of network chatter between the client and the server.
- Data being sent between the client and server is much larger than pre-1.3. Even on a vanilla Minecraft, the amount of data is significant. Unfortunately, I don't have the exact numbers with me.
- When we play from outside the office network (yes, our office has an official Minecraft server), we observed a lot of dropped packets and resends from the client. Which leads to more packets sent from the client (practically double the amount the server sends). Which translates to more bandwidth being used than normal. We tested this even on vanilla Minecraft. If we play within the office network (LAN), no lag issues whatsoever.
We are not certain as to why we are getting dropped packets. We haven't done enough testing yet to come to a conclusion. But we know how to workaround this.
THE WORKAROUND
If we want to play on our server from outside the office, what we do is create an SSH tunnel with compression enabled. With this, you minimize the data being sent and received, making the whole thing more efficient while minimizing lag. This practically eliminates the packet resending issue.
If you want to use this solution, you will need an SSH account on the server you play. You will probably need to have special permission from the server admin to do this.
To create the tunnel, here's the command:
ssh -L 25565:localhost:25565 -C -c blowfish [email protected]
Before you get scared and run away, let me explain each part:
-L 25565:localhost:25565 is the parameter that says "create a local tunnel that connects the server's port 25565 to my local machine's port 25565". That port is Minecraft's standard port. You will need to change that if your server runs on a different one.
-C is the parameter that enables SSH compression.
-c blowfish is the parameter that forces SSH to use blowfish as its encryption algorithm. This should reduce the amount of CPU used by SSH.
[email protected] is your credentials to login to your server. Change it with the actual username and hostname (or IP address if your server doesn't have a domain name associated with it).
Once your SSH tunnel has been established, login to Minecraft, go to multiplayer, and connect to localhost.
Enjoy!