Serverless DNS driven on-demand Minecraft server with Route53+Fargate+EFS
This is a tutorial I’ve put together for self-hosting a Minecraft server in a completely serverless environment using EFS for persistent storage. It’s designed to start up with a simple DNS query which means you just need to open Minecraft, wait about a minute, then refresh and the server will be online and ready. There’s a companion container that shuts it down when not in use and can also send texts through Twilio when the server is ready to go.
There’s other on-demand style minecraft server systems out there but they usually require some sort of special action to turn them on. This implementation is designed to be more automatic. I think it’s an interesting use case of the AWS stack and I wanted to share it. Thank you and enjoy.
Just out of curiosity, what’s the costs look like for a build like this?
EDIT: nevermind, I see it on the GH notes.
No worries. For quick visibility for anyone else.. about $0.50/mo for the Route53 hosted DNS zone, and basically free / pennies when it’s idle, and between 2 and 6 cents an hour when running depending on whether using spot or regular Fargate respectively.
That’s actually pretty crazy comparitively seeing that a typical hosted game server is… expensive.
By expensive do you mean $10/mo? Because small servers are about $10/mo.
Yes. Unless you are hosting a public server where people are on 24 hours/day, this solution amounts to around 25% less cost for even a heavy gamer (approx. 5 hours of play per day, 6 days per week). I’d consider 25% greater cost expensive, comparitively.
Ironically I just wrote practically the same thing in cdk for Q3 based game. My game image simply doesn’t change so I didn’t have a need for EFS and data persistence.
My server also shuts down automatically sometime at night so I don’t have to query itself on a weird port… Could …but bending over backwards would cost me a lot more than a fargate container over many years.
I also find strange CX that a user would look up a server and fail. What I did was create a rest API example.com/start/{region}that links to lambda that increments desired service count by one. Once the task is up, another lambda creates a DNS for entry.
We were so close. If I publish my work I will tag you. It’s all Iaac.
I’m sorry, that math doesn’t check out. Using standard Fargate pricing, the absolute minimum price per hour is about 5 cents. Using spot pricing you could get this down to 1.5 cents/hour, but spot pricing is not reliable nor are your instances guaranteed to be around. This works out to $6.50/mo for a reliable Fargate instance with 2GB of memory, or $1.95/mo for a potentially-unreliable fargate spot instance with 2GB of memory. Alternatively you can spend $4/mo for a reliable server on 24/7 without all the jank of an on-demand configuration, like this – which is 50% cheaper than a guaranteed fargate instance, about 100% more expensive than a potentially-unreliable fargate spot instance. We’re talking the price of a starbucks beverage here.
If you ever decide to build something that relies on spawn chunks (chunks that process 24/7, basically), the whole system turns against you. That’s say you build a mob farm and want to let it run while you’re away. As soon as you reach merely 7.5 hours of active server time per day, you lose advantage vs a server from a hosting platform.
To me this is solution is extremely niche, and has a lot of potential to cost way more money – especially for your “hardcore gamer” example.
DNS and socket triggers are a lost art. I love this. Great job
Odd CX, yeah but I was tired of my son interrupting my work asking to turn on the server. I was looking for a way to make it as easy as possible without requiring a static listener somewhere.
This could easily be modified in a variety of ways to trigger the action; most would require a browser/bookmark or a button/etc. SMS twilio webhook as a trigger would be great too. I felt the DNS pipeline was a neat way to try something different.
With respect to querying itself on a weird port, my watchdog container just runs netstat+grep+wc to get a connection count. In Fargate the network stack is shared so it works fine.
You literally gave a number of $10/month as a counter to what I said, which I accurately disputed as 25% more expensive than the OP’s numbers, comparatively, then replied again to tell me I’m wrong using a completely different number ($4/month). The number I disputed ($10/month), is still more expensive than the reliable Fargate costs you mentioned in your follow-up reply. Just stop.
When big iq gets crushed by mega iq, or basic arithmetic
This is really interesting. I’m half way (all projects are always half done) on a different approach for my boys as they want different servers for different versions, game modes, ops, etc. Still using containers but was on EC2 . I’ll take a look and might have a crack of combining the two approaches.
Nice one.
Dang.
I don’t play Minecraft anymore but this is a really interesting approach to hosting.
I’ve been meaning to build something similar, but by letting it run 24/7 using Fargate and EFS. This solution is neat…
Instead of updating the DNS manually, try using AWS cloudmap.
Don’t know if will work for your need, but its an unknown AWS service I discovered recently for a similar use case.
Great writeup.
I really like the idea of the launch being triggered by DNS query logging - great work!
This is a great tutorial on a couple of AWS services that I haven’t dug too deep into! Thanks for making this and sharing it.
I have occasionally hosted a Minecraft server for some friends, but I’ve frequently forgotten to turn it off again. I’ve wondered about how to make it on-demand before, and your solution is quite elegant! I dig it.
Thanks!