Monday, July 21, 2014

Adventures in Running a Personal Minecraft Server for Linux Admins

    So, I've been playing Minecraft for several years now. My wife, however, just started playing recently. Naturally, we wanted to play together. Sometime back in the history of Minecraft, the multi-player server code was merged in with the original single player game code, and thus even local single player games are run internally with a client/server architecture.  Because of this fact, Minecraft has has a nifty feature that lets you take a single player game you are playing, and "Open to LAN" which makes it multiplayer.

    My laptop was powerful enough to run the game with minimal lag for either of us, but this meant that she could not play if she had down time during the day while I was at work. We tried hosting the game off her laptop instead, but it could not handle the load and caused lots of lag and other problems for both of us, enough to make a survival game unplayable. The obvious solution to this was to run a server.

    Now, Mojang recently started their own hosting for Minecraft, known as Minecraft Realms. This is a nice self-contained option that handles all the administration and operation for you. There were just two problems. 1) I'm a Linux Engineer. If word gets out that I'm letting someone else run a server for me, I'll never hear the end of it at work. 2) More seriously, there is a monthly fee for using Minecraft Realms. It isn't much, clearly a lot less than purchasing hosting to run your own server. However, I don't have to purchase hosting. I get an allowance of cloud servers through my work (Rackspace, disclaimer at the bottom of the page, all views are my own and not theirs.) and I'm not currently using it all. So, I can have a decent quality server to use for free. Now, I just need to figure out how.

    I did some research, and I didn't really like most of the guides I found. I found that most of them were written for people who had never administered (or often even touched) a server before. As such, they either spent most of their time explaining the basics and glossed over the important stuff, or they just consisted of a list of (usually bad) instructions with no attempt at explanation at all. These might get someone up and running, but they won't have a clue what they did or how to fix it when things break. The other set I found was aimed at people who had lots of experience with various minecraft servers and were looking for a guide to some very specific tweak or another.


    One of the frustrations I run into, when trying to learn more about best practices and reference setups is that there is very little explanation of why people make the decisions they do. Even in the excellent /r/admincraft subreddit, there is a very deliberate attempt to not be opinionated on many topics, as you can see from the answers to their short FAQ. Basically everyone has their own ideas, you need to find your own path, etc. While true, it doesn't really give you a good starting point or a list of things to look into on your own.

    I eventually settled on this guide from /r/admincraft. I used it for my initial setup, and have since made a few tweaks and done some additional research. So, I'm going to give you my guide to what I have setup and why. I'm going to assume you are comfortable in Linux at least.

    Your first choice is hosting platform and location. Minecraft servers can be run from Windows or Linux servers (or Mac, but that isn't usually considered a server OS anymore.)  I prefer linux for my server duties, and it's what I do for a living so that was an easy choice for me. You can run the server from a machine at your house easily enough. (You can even run it from a Raspberry Pi.)You'll either need to give you players your IP address or use a dynamic DNS service and either way you'll need to setup some port forwarding on your router, but it can work quite well.

    If you want to step up from their to paid hosting, I'm going to point you to the /r/admincraft wiki for some advice. I run mine in the Rackspace public cloud, but I can't honestly recommend that for a personal server, as the one I'm running it on (2 GB Performance server) would cost me over $50/month if I were paying for it. 2GB is overkill for a server that currently has 2 users on it, and the cost is pretty high if you are footing the bill by yourself.

    Once you have decided where you are going to run it, you need to decide what "it" you are going to run. Once again the /r/admincraft wiki has a decent breakdown.

You can run what is known as "vanilla" which is the server software provided by Mojang. This provides you an unaltered experience from playing on a shared game for the official client. This is nice, but means you can't have any mods, and those can make your life as an admin nicer, or can add new features for your players, or can help your server be able to handle a larger number of players than it otherwise could. Minecraft Realms, the official hosted version, only allows 20 players to a server, and only 10 of them online at a time. Moving beyond the 10/20 player threshold is going to require beefy hardware, server modifications, or a multi-server setup. Nothing to worry about when you are starting out, but something to be aware of depending on your plans for your server.

    Craftbukkit is a server with an interesting history that I won't pretend to have right. What I think I remember from reading about it is it was created by a team that took the released minecraft server and then modified it. The modification allow for behavior and performance changes as well as mods/plugins. They created an API for mods, known as Bukkit. Eventually, most of this team was hired by Mojang to work on the official mod API (promised over 4 years, never seen. Maybe it will appear some day, but don't hold your breath. Many of the pages and sites about it have been pulled down. I'd expect to see Half-Life 3 before the official mod API shows up.) The things Craftbukkit give you over vanilla are additional configuration options to change server behavior and support for a rich community of mods.

    Spigot is a highly recommended server. It is a fork of Craftbukkit which contains performance tweaks. The tweaks are largely configurable and help your server to run more efficiently and with less lag. Being a fork of Craftbukkit, it implements the Bukkit API for mods, and therefore can use almost all of the same mods without any problem. One caveat to be aware of is that the tweaks Spigot makes (and even the ones you can do in Craftbukkit) are deviations from the behavior of a vanilla server. One example is entity grouping. In vanilla, if you drop a bunch of items on the ground, one at a time, they will all appear and behave as separate items, to be picked up or left to decay individually. Spigot, by default, will group any like objects within a 2.5 block radius into a single stack of objects. Performance wise tracking the location and status of one entity (the stack of objects) is much more efficient than tracking each one as a separate entity. It is, however, a behavior difference. Many players like it, but it can have an impact on certain machines that you may see people build in youtube videos, and then find out that they don't behave exactly the same on your server because of this. However, many of the largest multiplayer servers and server networks in existence run Spigot because the tweaks allow it to scale up much better, and it still supports all the mods.

    Cauldron is another option that I don't know too much about. I believe it is a Minecraft Forge server that implements the Bukkit Mod API. Forge is a competitor to Craftbukkit, I think, but I didn't find a lot of information on it.

    I chose Spigot for my server. I do run unto annoyances occasionally with little differences in how item elevators and hoppers work, for example. However, they are minor and I am quite happy with it.

    I'm going to end here, and will continue with a part 2 where I discuss a launcher, my actual install process, and add-on programs and their config.