Archive for November, 2009

EC2 Elastic Load Balancing for Fun and Profit

Monday, November 23rd, 2009

This one is so easy I don’t know why I haven’t gotten around to it sooner. It took my dev to be all, “OMG! The servers! How will we do a rolling deploy without impacting uptime!1!!eleven!” Thankfully, Amazon is there with Elastic Load Balancing (ELB) so I didn’t really need to get off my ass and be excited. Amazon Web Services: Doing the hard work so you don’t have to.

Before we dive in, a little background on operations. We’ve been making use of the elastic IP feature since it came out along with round robin DNS to handle the distribution of traffic over the web servers. Sure, it is crude and primitive but it works and I am a big fan of implementing the simplest possible solution since more moving parts results in exponentially more headaches. And, yes, we tried the HAProxy and the Nginx route but the cost+plus heartburn factor was too high for what we needed. Anyway, things have worked just fine with a minimum of effort on our part but our needs are changing so we need a solution that is both flexible and forgiving. Brittle is only good with peanuts.

First things first, create an ELB…

elb-create-lb eeniemeenie --headers --listener "lb-port=443,instance-port=8443,protocol=TCP" \
--listener "lb-port=80,instance-port=80,protocol=http" --availability-zones us-east-1c

Now you might be saying to yourself, “WTF, James. What is with the 443 => 8443 when 80 => 80?” Simple: “Currently, Elastic Load Balancing does not have SSL termination capability.” That basically means your application servers need to handle the SSL part but honestly this is fine because the way ELB is engineered the traffic between the balancer and your instances outside the firewall so you’ll want that traffic passing over SSL anyway.

Next, configure health checks…

elb-configure-healthcheck eeniemeenie --headers --target "TCP:8443" --interval 30 --timeout 20 \
--unhealthy-threshold 2 --healthy-threshold 2

elb-configure-healthcheck eeniemeenie --headers --target "HTTP:80/up.html" --interval 10 --timeout 5 \
--unhealthy-threshold 2 --healthy-threshold 2

These two health checks are intended to do different things. The one for TCP:8443 is to see if our application is up and serving (we force all traffic over SSL) while the latter is intended for rolling deploys, when we begin a deploy we’ll rename that file with the intention that the balancer sees it go missing and pulls the instance out of the pool. When everything is done and the deploy was successful we plop up.html back in and the balancer throws the instance back in the pool.

On the Apache side of things I decided to do a little mod_rewrite mumbo jumbo to deal with the new up.html file. Since I want all application related traffic forced to SSL the monitoring of that file by ELB presents a little wrinkle to my normal sledgehammer approach to things. Easily addressed though:

RewriteEngine on
RewriteCond %{REQUEST_URI} !(up.html)
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R]

Now, because I am a grumpy bastard I really don’t want up.html to be available over SSL.

RewriteEngine on
RewriteCond %{REQUEST_URI} (up.html)
RewriteRule ^(.*)$ http://%{SERVER_NAME}$1 [L,R]

That is basically it. Mind you, I have not punched this down for production but our initial tests have been very promising, in particular the rolling deployment feature.

(Parts of this solution were gratefully cribbed from Serk and Lead Thinking as well as the ever popular RTFM)

The Costs of Cutting Cable A Year Later

Monday, November 16th, 2009

This month marks the one year anniversary of our Post-TV experiment and while it is often hard to read Management on these things I am willing to judge it a success. However, there were some surprises in terms of consumption patterns and costs. Below are the numbers in the past year that we have spent at Amazon, iTunes, and Netflix:

Amazon Subscriptions
Anthony Bourdain: No Reservations Volume 6 – $18.90
Anthony Bourdain: No Reservations Volume 7 – $18.90
Deadliest Catch Season 4 – $30.24
Deadliest Catch Season 5 – $13.23
Guns, Germs, & Steel – $5.67
Swords Season 1 – $15.12
Andrew Zimmern’s Bizarre World Season 1 – $18.90
Bizarre Foods with Andrew Zimmern Season 4 – $18.90
Out of Egypt Season 1 – $11.34
Mad Men – $24.57
Shark Week 2009 – $11.34
Total – $187.11

iTunes Purchases
It’s the Great Pumpkin – $9.99
A Charlie Brown Thanksgiving – $9.99
A Charlie Brown Christmas – $9.99
Be My Valentine, Charlie Brown – $9.99
Arthur Season 11 – $9.99
Arthur Season 10 – $9.99
Dinosaur Train – $12.99
LazyTown – $17.82
Little Bill – $13.99
Mama Mirabelle’s Home Movies – $6.93
Martha Speaks – $24.99
National Geographic Channel Kids – $6.93
Oswald – $19.99
Sesame Street Vol 1 – $19.99
Sesame Street Vol 2 – $19.99
Sid the Science Kid – $16.97
Smithsonian Kids – $3.97
Super Why! – $9.99
The Adventures of Paddington Bear – $12.87
The Wind In The Willows Season 1 – $10.99
The Wind In The Willows Season 2- $10.99
Wallace and Gromit – $6.88
Wonder Pets – $19.80
WordWorld Season 1 – $10.89
Yo Gabba Gabba Season 2 – $17.91
Total – $324.82

Netflix
12 months @ $18.01/month – $216.12

MLB Live
$35 per year

Grand Total – $763.05

The biggest thing that struck me as I tallied up the numbers for the past year is that the costs of media acquisition are upfront and largely erratic when compared to the predicable subscription costs of cable or satellite as we found out in an effort to obtain programming for Gabi since pulling an over-the-air TV signal was an unmitigated disaster. What we saw in terms of outlay was a steep curve when we gave up on trying to get local programming and sought it on iTunes but after that initial binge purchases dropped off considerably–a little more than half of that iTunes total occurred in April. Amazon, on the other hand, has been relatively smoother with only a slight bump in late spring which oddly coincided with a weekend spent in a hotel with cable programming.

So while the total numbers are eye opening, an average of $60.67/month, I suspect that the next year will see these costs to continue to drop for a number of reasons. The large bump in costs was centered around going with a Plan B to make up for our inability to get a PBS signal over the air. Looking at the receipts I’d argue that our overall purchases are declining at a rapid rate because we have more content than we can watch based on our current media consumption behaviors. Which brings us to the biggest reason of all: we are hardly watching TV. Rather we are listening to music and reading or surfing the Internet, when we do watch TV it is in very focused bursts for a movie or a string of episodes.

Next year, I imagine the average monthly cost to decline by some 30-40% which would see us realize a substantial savings over the cable bill we had shouldered ($125/month for a satellite subscription through Dish and prior to that $145/month for a cable subscription, no Internet, through Comcast). While the savings is great really the biggest benefit that I am gleaning from the experience is a clearer head and a feeling that my free time is more productive.

Life outside the walled garden of subscription programming is just fine.

Donut Triptych or The Girl Is A Fastfood Artist

Saturday, November 14th, 2009