14 November, 2022
Minecraft is one of my favorite games. However, it is something I enjoy playing from time to time. This means that you will need to set up the server, install Java on the server, and run this java app on that server.
It eats at most 1GB of RAM, even when it is doing nothing and no one is around.
That's a bit of a bummer.
Introducing the mcod
This is the only issue I think I can "fix". I wrote a simple reverse proxy for Minecraft.
It works like this: If there is no one on the servers (90%+ of time in my case), the server is shut down. All that is left is the proxy. The server is restarted quickly after a connection is established. After the player leaves, the server is restarted after a short time to prevent flapping that could cause unneeded server restarts.
This is the default configuration of the proxy at the moment.
After running this for a while, I noticed that the server was being started quite a lot without a need and then shutting off after the TTL had expired. These were "banner requests" by clients who found my server in the list (or scans on the internet looking to find servers) and wanted to know how many players were playing.
To solve the problem of the server being started up unnecessarily, I added "banner cache". Now, when someone asks the server for a "banner", and the actual Java server was not running it would simply give the client its previous response from the java servers. This meant that I didn't have to start the Java backend just to see that there were zero people online.
The "-h" symbol of the program now looks like this:
It will by default cache the banners. It is worth noting, however, that this can be disabled and the StartServer/StopServer scripts modified if you wish to use it for other games.
This software assumes that it will run on its own user. This program should not be run on the same user that other Java apps. The StopServer script will automatically kill all running java apps.