8 ms·
Almost free serverless on-demand Minecraft server in AWS
- academia_hack 5y agoThis 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? 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.
- BiteCode_dev 5y agoPrivate minecraft servers as a service doesn't exist yet ?
- zimpenfish 5y ago> Private minecraft servers as a service doesn't exist yet ? They do but, afaik, there's no "spin up and down" ones that charge you for usage; they're all "$X per month" fixed cost. (Although looking at the costs these days, they're not that much higher than this would cost you for even a medium-sized world.)
- udbhavs 5y agoThere is https://exaroton.com/:en/ https://exaroton.com/:en/
- fastball 5y agoIf you're worried about idling in farms just auto-kick after 1 hour of AFK or w/e.
- Aeolun 5y agoWhy idle in farms? Can’t you just put down a chunk loader or something?
- fastball 5y agoIt's been a while since I played minecraft, so I don't know what a chunk loader is. When I played, if nobody was in the vicinity of the chunks with your farm in it it would unload and of course then the farm would not produce, so people would AFK in their farm to keep the chunks loaded.
- maybevain 5y agoSome Minecraft mods add items that force the game to keep certain chunks loaded. From the casual "Can't you just" I assume the parent meant those. It is however also possible, but much more complicated, to force the game to keep chunks loaded in Vanilla Minecraft. [0] [0] https://www.youtube.com/watch?v=dx5Wd28AKxQ https://www.youtube.com/watch?v=dx5Wd28AKxQ (the video is a couple years old so the current implementation might be different, but I think the basic principles are still the same).
- zimpenfish 5y agoilmango dropped a new chunk loader a few weeks back - https://www.youtube.com/watch?v=B8z7q_pwjL4 https://www.youtube.com/watch?v=B8z7q_pwjL4 Looks pretty easy to build.
- dasyatidprime 5y agoThat would have much the same cost effect if the server were kept up for it, and wouldn't be effective if the server were taken down.
- zimpenfish 5y agoIf it's a mob farm, a chunk loader won't work on its own, I think?
- deleted 5y ago[deleted]
- vultour 5y agoI 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.
- glecedric 5y agoAren't spot instances and Fargate preempt-able at anytime by AWS and/or AWS can throttle your instance as the cpu cores are shared like in a VPS ?. Do you just stop playing when it happens ?.
- vultour 5y agoYou can set it to automatically adjust the price so it doesn't get preempted. The price used to be essentially at a constant minimum (m4.medium/large) during the evening & night when we played, so even without that we never got preempted.
- mjlee 5y agoI'm afraid this isn't completely true. You can still be interrupted for capacity issues no matter what your bid is. It's quite rare on more common instance types, but becomes a problem if you have more than a few GPU or high memory type instances.
- Aeolun 5y agoI don’t think I’ve ever had my instances taken out from under me when I set the max price to the same amount as a normal instance. That said, when we exceed capacity we cannot boot any more instances, that’s definitely true.
- sharms 5y agoI thought this was true, but I have had spot instances go away even when going above reserved instance pricing.
- angulardragon03 5y agoYou 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. [1] https://www.oracle.com/cloud/free/ https://www.oracle.com/cloud/free/
- pantulis 5y agoOracle and "always free"? Boy are these interesting times...
- Mrdarknezz 5y agoAlmost sounds like a paradox
- bbarnett 5y agoThey're probably always free, until $x happens. Then there's an audit, you're found non-compliant, and now they own your house. Oracle, 2021.
- LadyCailin 5y agoFrom what I understand, suing people is a great business strategy. Much better than producing any actual value.
- lostcolony 5y agoI mean, it bought a Hawaiian island. Capitalism at its finest, really.
- gitfan86 5y agoI'm sure the TOS says "terms and conditions may change at any time in the future". Always is a trademark and not meant to convey any future services.
- 5y ago
- flatiron 5y agoFor all that work why wouldn’t they just use a droplet for $5 a month?
- sergiomattei 5y agoHey, it's a good resource for kids without money. Considering all the hours I spent looking for ways to do exactly this when I was 12-15... I don't doubt I would've gone through all the trouble and even learned some AWS along the way. Back in those days the only way I could get a free server was by hosting a phpBB forum on 000webhost and somehow convincing a VPS provider to "sponsor our forum". They'd get a massive banner ad and I'd get a free server to play around with. The good days!
- simonklitj 5y agoMan, I used 000webhost a lot! Thanks for the reminder.
- sergiomattei 5y agoIt was pretty great! There were a ton of free webhosts back then, they really fueled my creativity and desire to learn web dev. 000webhost, x10Hosting and SixServe (both had FREE cPanel!!), and never forget those shady reseller control panel hosts like Nazuka.
- depaya 5y agoHunting around for free cPanel hosting was essentially my part time job when I was 12-18. Many of them required certain forum activity too, so it could get time consuming.
- sergiomattei 5y agoSame here! Hours and hours searching. I'll admit though, the shady reseller hosts were pretty good. Terrible control panel aside, they had very generous CPU/bandwidth/storage limits compared to the free cPanel hosts that had to cut down the costs there.
- meekins 5y agoTo me a DNS lookup spinning up a container on Fargate looks both very cool and scary at the same time.
- AlfeG 5y agoBetter be sure not to share DNS name to anyone
- reilly3000 5y agoI’d never heard of the approach before and assumed it wasn’t possible so that’s a nice TIL- but ya relying on obscurity to contain costs seems like a recipe for a surprise bill.
- 7ewis 5y agoHave you found that any web crawlers have tried accessing your subdomain? Wondering if services like Google or Shodan may have tried querying it and causing your server to turn on?
- Pawka 5y agoSetting IP whitelisting would help.
- 0xbkt 5y agoYet be rather inflexible.
- doctorray 5y agoEither the subscription filter or the lambda could be modified to only fire based on source IP; not the whole thing but perhaps the CIDR of your ISP, so that only you can start it. Perhaps it could be done with the route53 geolocation options as well. In the 2 months I've been using this method before deciding to write it all down, I've not run into any issues with anyone else or any bots triggering the container to start, at least not yet...
- tlarkworthy 5y agoI made a service like this on Observable https://observablehq.com/@tomlarkworthy/minecraft-servers-be https://observablehq.com/@tomlarkworthy/minecraft-servers-be 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. It was based on the following terraform recipe (which I wrote) https://github.com/futurice/terraform-examples/blob/master/google_cloud/minecraft/main.tf https://github.com/futurice/terraform-examples/blob/master/g...
- endgame 5y agoAnother take on this is to intercept the login message and use that as the trigger: https://github.com/infinisil/on-demand-minecraft https://github.com/infinisil/on-demand-minecraft
- okdjnfweonfe 5y agoCould combine both: a vps running a login-message-only server, that spins up another server and then touches the DNS settings: As a bonus this "fixes" all the issues with proxying (doesn't erase the end user's IP or other such metadata for moderating)
- Aissen 5y agoConcerned 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? It's 2021 and the biggest cloud platforms still don't have hard limits on spending.
- sleepychu 5y agoDo you think it's an important feature for their paying customers? I've worked at places that care a lot about their AWS bill but I don't think any of them would have wanted a genuine hard stop before they'd do anything about it as a result of the soft alerts.
- geoduck14 5y agoI've used AWS for my personal projects and at work. When I started at work, I didn't fully realize that "when an EC2 is spun up, you are charged for 1 hour, even if you terminate it" - so I accidentally racked up a big bill. I was thinking it would be useful if Organizations could pre authorize users at $X before preventing them from doing more - of course the better solution is to manage releases through a pipeline that checks for stuff created and code scanning and... whatever In the end, we use cost monitoring, but no AWS billing alerts
- reaperducer 5y agoDo you think it's an important feature for their paying customers? I think it is. A few jobs ago, the boss of my boss got fired for a cloud service overage. Not a huge amount; the number on the grapevine was around $10,000. But it was enough. For many (numerically "most," probably) companies, the IT department is a black box to upper management, and any unexpected budget overages are a serious problem.
- hughrr 5y agoYeah. By the time you have woken up and read your billing alert email it’s too late. However the reason it doesn’t exist I suspect is twofold. Firstly because it is bad business. All the cloud providers make a lot of money from mistakes and small things sapping cash. Secondly it’s hard to rationalise what to do when the budget runs out. What do they nuke?
- 300bps 5y agoI always say the best way to learn a new technology is to work on a real-world project that you are interested in. The person that set this up got an amazing education on use of real-world AWS services. 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.
- Aeolun 5y agoMost people that move a whole set of on-prem machines to virtual servers actually need them on and available all day long.
- 300bps 5y agoWhat you're saying is true for a tiny minority of use cases. The vast majority of use cases are better off with variable resource availability. Unless you're doing something akin to mining cryptocurrency 24x7x365 most workloads are variable to some degree. So maybe instead of one giant server that processes requests you use a single small server that is available 24x7x365. Then if your workload increases at 8 am you use an autoscaling group to spin up 3 more. Then at 5 pm it goes back down to 1. And maybe you have a batch process that kicks off at 2 am every night so you spin up 4 servers to process requests. This is just one example so it's important not to focus on it and respond with, "Well what about x!" AWS has many ways to fulfill the promise of accomplishing tasks with minimal resources. And all of this is just a step on the path to serverless computing with things like Lambda and DynamoDB or serverless RDS.
- deleted 5y ago[deleted]
- aweiland 5y agoInstead of Twilio you could use SNS and subscribe to it via SMS. You would most likely stay within the free tier there too.
- unnouinceput 5y agoLately word "serverless" is used freely on HN. Want a clickbait title? use "serverless", damn be that only 4 words later "server" is used too
- mt_ 5y agoThe only thing missing is an IaC definition of this architecture.
- l30n4da5 5y agoId rather just host a minecraft server on an old desktop, and make it internet-available with playit.gg. A lot less chance of me spending $$ that way.
- horsawlarway 5y agoThis 100%. I don't even bother with playit.gg - just forward a couple ports on the router and pass out my ip. Only time my dynamic ip changes is when I lose power, and if I've lost power the server is down for "Maintenance" anyways.
- Fogest 5y agoOr you can just use a dynamic ip service and use that URL anyway. That would keep the IP up to date. That is what I have done for years and it has worked well.
- milesvp 5y agoDepending on the machine this might cost you more in electricity than a VPS. 100watts continuous costs something like $7/mo in a fairly low electricity cost region of the US.
- Fogest 5y agoThat would be assuming the machine is on 24/7 and only be used for Minecraft. A lot of Minecraft management systems allow the Minecraft server to be shut off when no players are on which would limit how many resources are being used on the machine 24/7 too. Overall I personally prefer a VPS or dedicated server but I don't think comparing it like you are is 100% fair.
- jonnycomputer 5y agoWhat is a serverless server?
- Nexxxeh 5y agoTo oversimplify, it's running the Minecraft server software in a way that behaves like it's running on a specific server. But in the background, it's run on a set of Amazon services. You don't have to rent a specific server for a given time period, like monthly server rental. You just use Amazon's on-demand services (that use whichever server resources are required at the time).
- jonnycomputer 5y agoThank you for that clarification. Aside from interacting with AWS MTurk, I haven't had much experience with Amazon's AWS, so it sounded like a joke.
- arduinomancer 5y agoserverless == ephemeral, on demand servers
- grey_earthling 5y agoHow is this different from “cloud”?
- pkilgore 5y agoGlad someone finished this. I got 90% of the way there using a lambda to find spot instances but got too busy to finish.
- 015a 5y ago> 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. 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. > Fargate launches two containers, Minecraft and a watchdog 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". 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. 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.
- messe 5y ago> It looks like the watchdog is simply checking for connections on a port, which is probably too low-level to handle with lambda Not at all. You could easily check that with any of Lambda's supported languages.
- 015a 5y agoIf the lambda were running on the same machine as the server, maybe, but that's not how lambda works.
- messe 5y agoAh you're right. I was thinking the watchdog was querying the server. I see now they're both part of the same fargate task, so it's just checking for local network connections.
- stjo 5y agoI wrote effectively the same thing without AWS lambdas https://playmcnow.com/ https://playmcnow.com/ 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. [1] For 15€/month you can have ~30 servers running in parallel and thousands of powered down worlds. https://contabo.com/en/vps/ https://contabo.com/en/vps/
- stjo 5y agoBTW, other fun hacks include: 1) Initial world creation is quite slow - 10-15 seconds on a moderately powerful hardware. Since I want first joins to be as fast as possible, I keep 1000 pre-generated worlds and one of them is chosen randomly to be used as template on your first login. 2) In addition to login packets, minecraft clients send a ping packet to check if the server is online. I forge a valid response because I don't want to start a server just so you can see "server is up, 0 players online".
- BeefySwain 5y agoThis gives me an idea for recycling the powered down worlds into "new" worlds for new users. Being able to see and use the abandoned bases of past players would be quite fun. You could take this a step further by "decaying" the bases in some way (remove torches, remove some large percent of the items in chests, add vines, weather rock, move blocks from the ceiling to the floor, etc)
- wst_ 5y agoThis is great idea, but may be tricky as people often just mess around with the world. You would need to, somehow, decide which abandoned base is visually appealing and/or matches the environment.
- stjo 5y agoIf my memory serves me correctly, it is rather easy to decouple natural from player made blocks. It was either stored separately on storage or at worst you can deduce it by "subtracting" a fresh chunk generated from the seed. Then you just need a good heuristic to guess whether or not a group of blocks matches your definition of a base to be explored.
- TheDudeMan 5y ago"ECS Fargate service to a desired task count of 1" This qualifies as "serverless" now?
- reilly3000 5y agoIt does, as its user has little control over the underlying hardware/VM and it’s intended for on-demand use cases. It’s managing a process rather than a VM. It’s definitely a gray area… is Heroku serverless?
- deleted 5y ago[deleted]
- bingohbangoh 5y agoGotta 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.
- shog_hn 5y agoI'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 https://www.shogan.co.uk/gaming/cheap-minecraft-server-in-aws-with-docker-and-traefik/ https://www.shogan.co.uk/gaming/cheap-minecraft-server-in-aw...
- stiltzkin 5y agoI would love to see this for Valheim.
- tgtweak 5y agoValheim dedicated servers are about the same overhead as a minecraft world (from what I can see running both side by side on windows anyway). It also supports linux, so you could probably do very similarly for Valheim.
- ylyn 5y agoThis is so complicated. 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. 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.
- balls187 5y ago> Then a simple webpage that sent an EC2 API request to power on the instance You send the EC2 API request directly from a public facing website?
- simonw 5y agoThis is a really smart setup, and superbly documented. 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. A regular non-software-industry-professional parent has little chance. 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.
- kaydub 5y agoPR a cloudformation template
- simonw 5y agoMy hunch is that even a cloudformation template would be way beyond the capabilities of most non-software-engineers. I wish AWS would provide some kind of interface where I can redirect a regular human being to easy-deploy.aws.com/?cloudformation=url-to-my-cloud-formation and they would be presented with a human-readable form that tells them what it will do, sets a hard limit on how much money it will be able to burn through (for protection against crypto-currency mining scams), enter their credit card details and click "Deploy" to start using it.
- bussierem 5y agoI'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: 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!
- doctorray 5y agoThanks so much, I really appreciate your comment.
- soobrosa 5y agoI'm like why all this overengineering instead of deploying on a cheap EC2 like to be used _all the time_.