Posts Tagged ec2

Cheaping out on EC2 – using Spot Instances

Amazon markets Spot Instances as a way to reduce the price you pay for instances. So, continuing my efforts to reduce expenses on EC2, I looked into using spot instances. Spot instances are essentially just like normal instances. You can create your own AMIs, where you essentially create an image and tell Amazon to create instances based on that image, or use an existing AMI.

If you want to create an AMI, get a starting image, and customize it as necessary. I started with the Fedora 17 image. In an attempt to reduce the cost, I resized the disk from 10GB to 2GB, installed vim, less, screen and rsync, which oddly aren’t in the default Fedora install.

I then had to package it as a new AMI – this created an EBS snapshot, so I’m happy that I resized the disk. It’s a bit annoying that you’re going to be paying for an EBS snapshot AND the active EBS volumes, but in virtually all cases, the cost of the EBS snapshot won’t exceed the amount saved by using spot instances. If you have a bigger snapshot, it’ll cost more of course, but then you’d likely be using a more expensive EC2 instance, so the cost should balance out in the long run.

As for actually using the spot instance, I had my AMI set up to automatically start an IRC bot, so I used this for timing. The IRC bot came online ~7 minutes after I submitted the request to start the spot instance, so there’s a bit of lead time, but not too much. Because of the lead time, the instance won’t appear in the instance list for a while.

And an extra tip: Don’t be like me and not realise the spot instance actually started, and leave it running for two months racking up charges, only to be notified by Amazon that you now owe them money after your credit runs out. (Thankfully, they waived the charges as a one time thing.)

So now by default I set an expiry time of a day on all my spot instance requests if I know I’m only going to have them up for a few hours.

And one thing to look at if you require access to your data and can get by with using a pre-created image is using instance stores and mounting EBS volumes with the API. I didn’t try it because apparently, the t1.micro size that I’m using doesn’t support instance stores. Of course, this only really makes sense if you don’t want to pay the cost of having the spot instance run off an EBS volume. For a large scale operation, could be worth it.

, , ,

No Comments

HLDS on EC2

Update Jul 2014 – use the shiny new SteamCMD tool. Also, I started using DigitalOcean instead of EC2 (marginally cheaper, incredibly easier to setup)

Create a Instance – spot works

Install wget, tar, ncompress – depends on your distro, fedora 17 by default didn’t come with this (which, btw, is WTF?!) Also, screen to run disconnected from the server, and vim for text editing

wget http://media.steampowered.com/client/steamcmd_linux.tar.gz && tar -xvzf steamcmd_linux.tar.gz && ./steamcmd.sh

download the actual HLDS server

mkdir tf2 && ./steamcmd.sh +force_install_dir tf2 +login anonymous +app_update  232250 +quit

setup the config files

cd tf2/orangebox/

touch cfg/server.cfg && vim cfg/server.cfg – specify what you want, I pulled mine from forums.srcds.com/viewpost/67692#pid67692

./srcds_run -game tf -autoupdate -maxplayers 32 -console +map mvm_coaltown

Notes:

Pull map names from TF2 wiki, eg wiki.teamfortress.com/wiki/Mann_vs._Machine_%28game_mode%29 has the map filenames listed under “Maps”.

If you’ve got iptables running *in addition to* the aws security groups, disable iptables, or allow exceptions for the HLDS ports (UDP 27000-27015).

A t1.micro instance *isn’t* suitable for a tf2 server. The way Amazon has it set up is that Micro instances will have their CPU stolen by other instances if necessary. While this rarely happens to any great effect, when it does, there’s a large ping spike.

List of console commands, unknown how many map to the server: developer.valvesoftware.com/wiki/List_of_TF2_console_commands_and_variables

Official Valve post on setting up HLDS: support.steampowered.com/kb_article.php?ref=6758-TCMF-2234 (Wasn’t too helpful, also Windows specific.)

On the client, you have to set rcon_password to the server password, *then* issue rcon commands. Doing “rcon password” in the client won’t work.

Some other stuff relating to HLDS here: wiki.teamfortress.com/wiki/Linux_dedicated_server

Potential mods: www.mani-admin-plugin.com/cms/index.php/about and wiki.alliedmods.net/SourceMod

18th Aug update:

For some reason, auto-update failed, had to manually update.

3:07 Updating 'Team Fortress 2 Content' from version 350 to version 352

A symptom was a bunch of messages showing up in the log:

MasterRequestRestart
Your server will be restarted on map change.
Your server will be restarted on map change.

Also, a bunch of config changes coming too.

Aug 19th: Since I’m jumping between EC2 regions spinning up servers as and when I want to play on them, a ‘one’-line command to get the TF2 server up & running is now here

Also, 3 files are edited in the orangebox/tf folder: cfg/server.cfg, mapcycle.txt and motd.txt

A pretty extensive sample server.cfg was posted here: forums.steampowered.com/forums/showpost.php?p=32341843&postcount=1

If the servers were going to be around for a while, register them with Valve as per support.steampowered.com/kb_article.php?ref=2825-AFGJ-3513 for Quickplay support

More plugins: forums.alliedmods.net/showthread.php?t=84801, www.sourcemod.net/newstats.php?mod_id=558&addon_id=0, forums.alliedmods.net/showthread.php?p=592536 and forums.alliedmods.net/showthread.php?p=532620

RCON Guides: forums.srcds.com/viewtopic/13192 and www.uk-tf.co.uk/index.php/rcon-guides#Kicking%20&%20Banning%20players

, , ,

3 Comments

Cheaping out on EC2 – Downsizing existing EBS volumes

I’m moving a VM from my own server to EC2. I’ve got $50 worth of credit from a Redhat event, so I would like to make use of that. (That, and my AWS account existed before the free tier was introduced, so I’m not eligible for that.) That said, I want to make that credit last as long as possible. There were two parts to this – resizing the EBS volumes so I don’t get dinged for more than I need.

Amazon says $0.10 per GB-month of provisioned storage – so I’d be paying ~80 cents/month for storage that I’m not using. Admittedly, it isn’t that much, but that’s where I looked first.

Read the rest of this entry »

, , ,

2 Comments

Removing bloat from Fedora 17 on EC2

I’m in the middle of trialing EC2, and I’m using the official Fedora 17 images kindly provided by the community.

They make a great starting point, because I can then install my needed software.

Some of which, though, I consider absolutely crucial. So far, I’ve need to install vim, less, rsync and screen. I can forgive rsync and screen, and to a certain extent less… but vim?

Especially when things like NetworkManager, ModemManager and mobile-broadband-provider-info are taking up space. Then there’s stuff like plymouth – we’re not seeing a graphical boot screen, so I should be able to erase this, right?

I hope that I don’t have to roll my own AMI image though. Just modify this one as needed, and create an AMI out of it. Read the rest of this entry »

, ,

1 Comment