CPU: Not enough! 512MB: Not enough! Annoying delay which disturbs the playability…
So I first planned buying a home server
I remembered what I’m doing at HDE
Use the cloud and save money!
Solution: EC2 Spot Instances!
m3.medium vCPU: 2 RAM: 3.75GB
$0.101/h for an on-demand m3.medium instance
m3.medium for about $0.01/h (today’s price)
The price varies over time
but spot instances are generally very cheap!
My First Plan • When I want to play, • API bids for a spot instance • Spot instance boots up and mounts a particular EBS, via cloudinit script • Instance registers itself on a DNS to make it easily accessible from the client
But this is difficult • How do I control this from outside of EC2? • I want to casually switch the server on and off
Auto Scaling Group
Auto Scaling Group Example: Min:1 Max:4 On low load On high load
But we don’t auto scale at all ;-)
We scale manually
Auto Scaling Group Min:0 Max:0 When we are not playing minecraft Min:1 Max:1 When we are playing Me minecraft Kid
And made a UI for kids
Capacity: 0 Started: No Up: No
Capacity: 1 Started: No Up: No
Capacity: 1 Started: Yes Up: No
Capacity: 1 Started: Yes Up: Yes
Python + boto + Flask Lines: 74 (excluding HTML templates) So easy!
I only pay 10-30 JPY per a week for this!
Other tweaks • I’m actually using “desired capacity” feature of auto scaling group to control the number of the instances • Instance uses dynamic-DNS to bind it’s IP to a fixed FQDN • Instance watches the Minecraft directory and terminates itself (sets capacity to 0) if there are no activities for an hour • Anyway the server kills itself after certain hours
This technique is also useful when you have to keep a non-critical server up