There comes a time in the life of every extended family, where though they may be divided by great geographic distance, they remain united in their desire to stay connected...by joining together and playing Minecraft on a shared server.
OK. Maybe that doesn't happen in all families. And, I must confess, maybe not everyone in ours was quite so united. But, after various grandparents, and aunts, and uncles all expressed a desire to join in on the tree-punching, ore-mining, zombie-slaying fun, it was clear we had to make the family Minecraft server happen. And, as the programmer in the family, that job fell to me.
At first, I tried running the Minecraft server on the Mac Mini tucked away in our living room that doubles as our home entertainment center, but when the kids discovered that we were unable to stream Netflix and run Minecraft at the same time, that proved to be a very unpopular solution.
At that point, the easy thing to do would have been to lease a Minecraft server from a hosting company that specializes in that sort of thing, or maybe use a cheap VPS from Digital Ocean, but I had a different idea. It occurred to me that our family Minecraft server wouldn't be used all that often. Perhaps a couple hours a night, at most. So, why should I pay for a server to run 24/7?
Wouldn't it be
more interesting more fun more economical to run the server only when we were playing, and then shut it down when we weren't? We wouldn't just be hosting Minecraft...we would be running Minecraft in the cloud! How buzzword-y!
And, thus, "Minecloud" was born.
Problems to Solve
While a solid concept, my on-demand, cloud-based Minecraft server idea had a few obstacles to overcome before it was ready for prime time.
First, I needed a way to save the state of the Minecraft world, so that you could shut down the server today, and then, when you launched it tomorrow, you would return to the exact same time and place in the world. (Players get very cranky when their elaborate castle additions disappear because their last few hours of work weren't saved properly.) Of course, all that world saving and restoring had to happen automatically behind-the-scenes.
Second, launching a Minecraft server needed to be easy enough so that everyone from an 11-year old to a 70-year old could do it. That ruled out the first couple of options that came to mind for starting a server, like running a script, or logging into the complicated admin panel of a Web host provider. While I may be comfortable with those options, I didn't want to inflict them on the rest of the clan.
Instead, I envisioned a Web interface with a single button:
Click it once to "Wake Up the Server." Click it again to "Shut Down the Server."
What could be simpler?
But, That's Not the Whole User Experience...
Unfortunately, even if I make the process of launching a server ridiculously simple, I must admit that it still does complicate the process of starting to play Minecraft.
With your typical, always-on Minecraft server, here's the process of preparing to play:
Launch Minecraft client.
Click on "Join Server."
In constrast, here's how the Minecloud process would work:
In your browser, go to the Minecloud Web application.
If your Minecraft server isn't already running, click the "Wake up Server" button.
Wait for the Minecraft server to launch and be ready. (Grabbing a cup of coffee during this step is optional, but highly recommended.)
Get the IP address of the Minecraft server from the Minecloud Web application.
In the Minecraft client, edit the Server configuration and add the new IP address.
Click on "Join Server."
So, there's a tradeoff. Using Minecloud is a little more complicated for players, but hopefully, it's still easy enough to be worth it for the savings in hosting costs.
Making the Minecloud Vision Real
The solution I came up with consists of two parts:
- Configuring a virtual machine with all the software necessary to manage and run a Minecraft server.
- Running a Web application that launches and terminates the virtual machine.
Minecloud relies heavily on Amazon Web Services. Their Elastic Cloud Compute (EC2) service allows you to pay for servers in 1 hour increments, so it's perfect for a short-lived Minecraft server, while their Simple Storage Service (S3) solves the problem of where to store backups of the Minecraft game data files. And, the combination of their API and the fabulous boto python library make it easy to programatically utilize AWS services.
As for the Web application, I designed it to run on Heroku's free services, to keep costs down even further.
In the next couple of blog posts (Part 2), I'll discuss what went into building the two different parts. In the meantime, here are links to the Github repositories for each part of the Minecloud project.