I wrote effectively the same thing without AWS lambdas <a href="https://playmcnow.com/" rel="nofollow">https://playmcnow.com/</a><p>It’s so cheap[1] to start and stop servers on demand that I’ve decided to give “away” servers for free. I wrote a little proxy in Go that detects minecraft login requests and starts a server with the specific world. After a dropped connection I stop it.<p>[1] For 15€/month you can have ~30 servers running in parallel and thousands of powered down worlds. <a href="https://contabo.com/en/vps/" rel="nofollow">https://contabo.com/en/vps/</a>
You can host Minecraft servers for free on Oracle Cloud’s “Always Free” tier [1] now that they’ve added free ARM cores. You get 4 cores and 24GB(!) of RAM to assign to up to 4 VMs - more than enough for a server for friends or family.<p>[1] <a href="https://www.oracle.com/cloud/free/" rel="nofollow">https://www.oracle.com/cloud/free/</a>
> The DNS lookup query is logged in Route 53 on our public hosted zone.
> CloudWatch forwards the query to a Lambda function.
> The Lambda function modifies an existing ECS Fargate service to a desired task count of 1.<p>I had never heard of this architecture before; a pretty creative way of doing Heroku-like scale-to-zero at nearly no cost on AWS.<p>> Fargate launches two containers, Minecraft and a watchdog<p>I'd love to see a cost analysis between running the "watchdog" as a Fargate container versus another lambda function. Even having a lambda function run once every 5 minutes 24/7 would trigger ~15,000 invocations a month, which is in the realm of "near Free".<p>If there was some way to trigger the scale-down event from there, it would reduce the expensive part of this setup (Fargate) even further. Though, granted; given both containers are packed into the same Fargate VM, it would really only mean freeing up some additional resources for the Minecraft server.<p>It looks like the watchdog is simply checking for connections on a port, which is probably too low-level to handle with lambda. But, an architecture like this could work in a ton of services, and if you had e.g. an ALB set up in front of the services, one could use the lambda to scan incoming request metrics and scale down on that.
I always say the best way to learn a new technology is to work on a real-world project that you are interested in.<p>The person that set this up got an amazing education on use of real-world AWS services.<p>A lot of IT people aren't aware that things like this exist. They think moving to the cloud means sending all your virtual servers to your provider of choice and running them 24x7 like you did on-prem. In my opinion it's more about architecting solutions so that resources pop into existence for the exact # of milliseconds they're needed and then they're released. This is a clever step along that path.
I made a service like this on Observable<p><a href="https://observablehq.com/@tomlarkworthy/minecraft-servers-be" rel="nofollow">https://observablehq.com/@tomlarkworthy/minecraft-servers-be</a><p>it never really took off so I mothballed it, however, I do use it at home for our personal server and it has saved me a ton of money! It makes perfect sense as you can have quite a good spec machine when you are paying by the hour. you just disconnect the disk from the VM and pay for disk storage which is very cheap.<p>It was based on the following terraform recipe (which I wrote)<p><a href="https://github.com/futurice/terraform-examples/blob/master/google_cloud/minecraft/main.tf" rel="nofollow">https://github.com/futurice/terraform-examples/blob/master/g...</a>
This is awesome! I'm still afraid that one of my friends will go on a Minecraft binge (or idle in a farm) and drive up the costs beyond the $13/month or so I pay for VPS hosting but I think this approach would objectively be quite a bit cheaper for the casual vanilla SMP server I run for a dozen or so folks. Anyone know how to estimate the "worst case" monthly cost for this config?<p>Edit: Just saw that the GitHub includes a link to an AWS calculator. Looks like a month of continuous usage caps out at $40-ish. Not too bad since my realistic worst case is probably more like 8/hrs per day rather than the full 24.
I've seen one offhand comment about this so far from someone else, scrolling through the comments here. Wanted to make it a top-level comment though:<p>This is PHENOMENALLY DOCUMENTED. I am thoroughly impressed, @doctorray. Clear and easy to follow walkthrough and explanation of how it works, amazing troubleshooting tips, suggestions for managing it... This is an exemplar of a well-made README for a service. Bravo!
I ran Minecraft on spot instances when we used to play in university, complete with automatic terraform+ansible provisioning and automatic saves/backups in S3. Never used Fargate but I doubt it can beat spot instance pricing. More than half my bill was network traffic.
Another take on this is to intercept the login message and use that as the trigger: <a href="https://github.com/infinisil/on-demand-minecraft" rel="nofollow">https://github.com/infinisil/on-demand-minecraft</a>
I've got a Minecraft server running in AWS with a graviton / ARM spot instance + EFS for persistence. It's also cheap to run (I run mine 24/7 and it hosts multiple other services as docker containers). Cost ~$10 per month. Infrastructure deployed with aws-cdk<p><a href="https://www.shogan.co.uk/gaming/cheap-minecraft-server-in-aws-with-docker-and-traefik/" rel="nofollow">https://www.shogan.co.uk/gaming/cheap-minecraft-server-in-aw...</a>
Have you found that any web crawlers have tried accessing your subdomain?<p>Wondering if services like Google or Shodan may have tried querying it and causing your server to turn on?
This is a really smart setup, and superbly documented.<p>I just wish there weren't so many steps to get this kind of thing running! Even with automation it's still a LOT - getting this running myself would take me a few hours, and I have prior relevant experience.<p>A regular non-software-industry-professional parent has little chance.<p>I really wish there were better ways to make AWS stuff like this available for people to use without requiring them to have deep knowledge of how to work with different aspects of AWS.
This is so complicated.<p>I did this with a Minecraft plugin that would schedule a systemd shutdown in 30 minutes when the last player disconnects, and cancel the shutdown if a player connects.<p>Then a simple webpage that sent an EC2 API request to power on the instance, and a simple plugin that sends a Telegram message when the server is ready for connections.
Gotta say, I never had good luck with AWS Lambda Serverless. Blew through the free quota playing around with a django app deployed using Zappa. Never got out of the "let me make sure this works when deployed" phase.
Id rather just host a minecraft server on an old desktop, and make it internet-available with playit.gg.<p>A lot less chance of me spending $$ that way.
<p><pre><code> Concerned about cost overruns?
Set up a Billing Alert! You can get an email if your bill exceeds a certain amount. Set it at $5 maybe?
</code></pre>
It's 2021 and the biggest cloud platforms still don't have hard limits on spending.
Lately word "serverless" is used freely on HN. Want a clickbait title? use "serverless", damn be that only 4 words later "server" is used too