Building a minecraft server for a family using Auto Scaling Groups


Published on

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Building a minecraft server for a family using Auto Scaling Groups

  1. 1. Kazuhiro Ogura @goura 小椋 一宏
  2. 2. Building a Minecraft Server for Families (Using AutoScalingGroup) Kazuhiro Ogura HDE, Inc.
  3. 3. Of course you know about Minecraft
  4. 4.
  5. 5.
  6. 6. I’m playing this game for about a year
  7. 7. …with my 7-years old son
  8. 8. Minecraft is not an MMO
  9. 9. But It’s an MO (Massive Multiplayer Online Game)
  10. 10. P2P Play PC (Host) PC (Guest) PC (Guest) PC (Guest)
  11. 11. Not for a kid/dad who doesn’t live in the same timeframe
  12. 12. Dedicated Server Server (Host) PC (Guest) PC (Guest) PC (Guest)
  13. 13. minecraft_server.jar • Free • Distributed as a jar file (Need JRE to run) • Official version from Mojang, 
 open source clone also available (Bukkit)
  14. 14. So I started like this
  15. 15. Server (Host) My PC (Guest) Kid’s PC (Guest) Sakura VPS RAM: 512MB Daytime
  16. 16. Server (Host) My PC (Guest) Kid’s PC (Guest) Sakura VPS RAM: 512MB Nighttime
  17. 17. Server (Host) My PC (Guest) Kid’s PC (Guest) Sakura VPS RAM: 512MB Weekends
  18. 18. This worked
 for a while
  19. 19. Kid builds in daytime, dad mines at night
  20. 20. Kid builds in daytime, dad mines at night
  21. 21. On weekends we explore scary places together Image taken from:
  22. 22. But the happy times didn’t last forever
  23. 23. Complexed structures raise the server load
  24. 24. Example: Automated Chicken Cooking Machine
  25. 25. Red stone circuits
  26. 26. CPU: Not enough! 512MB: Not enough! Annoying delay which disturbs the playability…
  27. 27. So I first planned buying a home server
  29. 29. I remembered what I’m doing at HDE
  30. 30. Use the cloud and save money!
  31. 31. Solution: EC2 Spot Instances!
  32. 32. m3.medium vCPU: 2 RAM: 3.75GB
  33. 33. $0.101/h for an on-demand m3.medium instance
  34. 34. m3.medium for about $0.01/h (today’s price)
  35. 35. The price varies over time
  36. 36. but spot instances are generally very cheap!
  37. 37. 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
  38. 38. But this is difficult • How do I control this from outside of EC2? • I want to casually switch the server on and off
  39. 39. Auto Scaling Group
  40. 40. Auto Scaling Group Example: Min:1 Max:4 On low load On high load
  41. 41. But we don’t auto scale at all ;-)
  42. 42. We scale manually
  43. 43. Auto Scaling Group Min:1 Max:1 Min:0 Max:0 When we are playing minecraft When we are not playing minecraft Me Kid
  44. 44. And made a UI for kids
  45. 45. Capacity: 0 Started: No
 Up: No “Stopped” “Start”
  46. 46. Capacity: 1 Started: No
 Up: No “Told the server to start up.” “Please stand by.”
  47. 47. Capacity: 1 Started: Yes
 Up: No “The server
 started.” “Wait for 
 a minute.”
  48. 48. Capacity: 1 Started: Yes
 Up: Yes “It’s running.” “Stop”
  49. 49. Python + boto + Flask Lines: 74(excluding HTML templates) So easy!
  50. 50. I only pay 10-30 JPY per a week for this!
  51. 51. 社長だけど
  52. 52. 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
  53. 53. This technique is also useful when you have to keep a non-critical server up
  54. 54. Happy Mining!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.