6

A way of running Minecraft servers on AWS and automatically hibernate instances when there are no players online.

Project Type
Open source idea
Summary

A way of running Minecraft servers on AWS and automatically hibernate instances when there are no players online.

Description
Minecraft servers require a lot of resources to run, and unless you have the ability to host it on your own hardware it becomes pricey fast. AWS allows you to hibernate an EC2 instance and have it hibernated for practically no money, and that could be used to disable the server when no-one is online, potentially saving a lot of money over time. Velocity provides a plugin API and using it's hooks player count can be tracked and incoming connections can be detected. I literally came up with this just today during a long trip, so just wanted to hear if someone was open for a collab. Probably won't have the motivation to get this across the finish line myself atm.
Tech Stack
Go, Node.js, or perhaps something even better
Current Team Size
1, only me
Comments
  • 1
    Is Hibernate the same as stopping? If so, I think it would incur storage costs

    Also, serverless sounds like it is doing what you want
  • 2
    @asgs Hibernation isn't the same as stopping, at least not at AWS. Though you're correct that some storage costs would be unavoidable. That being said storage is cheap, and definitely cheaper than having the server run 24/7.

    And I haven't ever touched serverless, but based on what I've heard I don't think it's suited for Minecraft servers.
  • 2
    Short answer: you can't, at least not in a way that would be cheaper than running your server 24/7.

    Long answer: Minecraft protocol dictates that your server needs to have a fixed endpoint and session from the start, and doesn't support redirects. This rules out any possibility of using lambda or another event-driven listener for incoming connections, that would in turn start your instance and redirect any further requests to it. It also rules out the possibility of using some sort of routing rules to internally do the forwarding, because it would disturb the session (although it might work for the first player to start a session, wait a minute or so for the internal VPC redirects to come in place, and then join again within some grace period before instance goes back to hibernate). Anyway, even though it is technically possible, you would at minimum need either a NAT + lambda, or a small proxy instance you'll keep online 24/7.
  • 0
    @hitko NAT would cost you about as much as running a 15-person server 24/7, while the smallest feasible proxy instance costs 50% of a 5-person server.
  • 0
    @hitko Yes, a proxy is in order. That's also why I mentioned Velocity. You could probably get a way with a single proxy server for multiple instances, cutting the costs even further. I think that pretty much answers your comment.
  • 1
    Hasn't that been a thing for quite some time now? I remember seeing "Please try again in a minute, server is starting up" when connecting to a server.
  • 2
    @ScriptCoded Keep in mind that you're looking at really low numbers here. It's like the birthday paradox, even with only a handful of players the probability of someone being online at any given time quickly approaches 1 (see image for the general shape of the related probability distribution). At those low numbers, the proxy instance costs you almost as much as the actual server instance, so the only way to make it viable would be if you could somehow get rid of the proxy instance and instead use some "nearly-free" AWS solution such as lambda, but as discussed in my first comment, that's not possible.
  • 0
    @synemeup Possibly. If you have a link I'd be happy to check it out :)
  • 1
    Searching for "minecraft server hibernation" gives me this: https://github.com/gekigek99/....

    It's apparently written in Go. Maybe it's possible to modify it to properly work with AWS :D

    Neat stuff.
  • 1
    @hitko Well, no case is like the other. I'm running a server with a few friends, and we all live in the same country and don't really play during the days. Some days we don't play at all. If I were to guess I'd say we utilize no more than 20-25% during a month. Add to that that a Minecraft server requires a lot of resources and I think I'd save a buck. I might run the numbers tomorrow just to check. Also, in our case it's also a modded server, which means even more demand for resources.

    So no, it probably isn't for any server, but with a bit of load I think it could make sense.

    I'll try and run the numbers tomorrow
  • 1
    Sounds like open source alternative to Aternos.
  • 2
    @ScriptCoded Look, the cheapest instance you could use on AWS costs $0.0047 per hour, and I'm not even sure it could run Velocity for a single player, since it only has 512MB RAM and most of that would be consumed by OS and JVM. You'll probably need something at least twice as expensive just for the proxy, which adds up to about $7 per month. Running a proxy means you'll also pay $0.01 per GB of internal traffic between the proxy and the server, which adds to about $0.3 per hour of play time. Then there's an extra disk which might be cheap, but it still adds about $2 per month. That's already $21 per month just from running the proxy server 24/7 and playing 40 hours per month. For comparison, most game server providers charge less than $20 per month for dedicated Minecraft servers that can support between 8 and 15 players (modded) and up to 40 players without any mods.

    That's how thin those margins are.
  • 1
    That would be interesting to have, I tried with some connection detection mechanism inside the EC2 instance linked to an EIP, but Minecraft always timed out the connections because it was expecting the server to be already alive.
    I started looking to develop a Discord bot for this but didn't get far (primarily because of time and money).
  • 0
    @hitko Well, firstly, nothing is forcing you to run the proxy on AWS. You could very well run it on DigitalOcean, or any other provider. A $5 Droplet has plenty of capacity for the Velocity. Velocity doesn't really require a lot of resources. It's lightweight AF. You can get away with 1GB of RAM with no issues whatsoever in my experience.

    Secondly, the more servers you host the cheaper that steady cost becomes if you look at it on a per-server basis. Me myself is currently running 2-3 servers, and I have a friend who I'm sure wouldn't have anything against having his server run cheaper as well. That pretty much negates the steady cost.

    Using RAM as a baseline, two of my three servers run with 8 GB, and assuming i utilize them to 25% (averaged out it's probably closer to 15%) I could run the server itself at $20 a month instead of the $48 I pay today. That's not including the cost for the proxy, but at these figures it's already a win.
  • 1
    @Berkmann18 Well, if you'd be interested in bouncing off a few ideas I'd be happy to talk.
  • 0
Add Comment