«Back to blog home

Amazon Series: Leveraging Amazon Web Services for Practical Scalable Applications (Part 1)

So I recently just finished a project here at Purple, Rock, Scissors. Web Design and Development Firm / Digital Agency in Orlando, FL.  It was the first time we were asked to provide a quick setup and a low cost solution for scalable web hosting.  Instantly, Amazon EC2 with Elastic Load Balancing came to mind.  I find that many IT professionals have a strange fear of "Cloud Hosting".  This isn't all that uncommon though.  Many IT Pro's fear the unknown and choose to bash it rather than embrace technological advances.  

Before anyone bashes me though for being an obsessed "fanboy", I do not always utilize AWS or other Cloud Providers.  While cloud hosting has many advantages, it is certainly not for everyone.  Every client has different needs and therefore AWS does not get recommended to all of them.  Most clients who request help with hosting still get directed into a traditional hosting plan with our favorite provider Peer1.  They have datacenters all over the US and have the flexibility to meet most of our clients' needs.  It also gives the flexibility to upgrade / downgrade to meet the ever-changing needs of our clients.  

We actually used ourselves as a test case starting last year.  We run both our Zimbra mail server and our Drupal website on a single small instance for about $80 / month.  That is a pretty good pricepoint for the amount of use we get out of the server.  The only caveat to running mail on AWS is that they don't provide reverse DNS entries, which means that you need to use a 3rd party SMTP service such as AuthSMTP.  For us, this works out to an additional $160 / year, which still makes it more economical at a total cost of $1120 / year.  This is roughly 20% of what we used to pay in a traditional hosting model.  Not only that, but should we need additional capacity, we can simply turn off our server, request the next largest size instance, and be up and running again in under 20 minutes.  

However, in our use...we are using a single Amazon EC2 small instance.  Setting up a load balanced environment is a whole different ballgame that we got to experience.  Let's dive in and look at setting up a sucessful load balanced environment utilitizing Amazon Web Services. 

Step 1

First, go ahead and sign up for an account at http://aws.amazon.com.  If you already have an Amazon account for buying things on Amazon, the same exact account can be used...you just need to enable web services.  Once you have that set up, go ahead and grab your X.509 certificate, Access Key and Secret Access key from the "Security Credentials" section of your account. 

Step 2

There are many admin panels available for Amazon.  I recommend using the AWS Management Console in EC2 mode.  This is available directly from the AWS site.  If you only need basic EC2 functionality, you can download ElasticFox for managing EC2 and S3Fox for managing S3 buckets directly from Firefox. I still recommend the Amazon panel though, as you can log into the interface without special Firefox plugins.

Once you are in the admin panel, you will see an interface similar to this:

The image above shows off the AWS Admin Panel.  It gives us a heads up display of all the things that are currently in use in our account.  Let's take a few mins to explain each of the sidebar elements:

  • Instances
    An instance is an amazon machine image or "AMI" which has some current runstate.  It could be Pending Deployment, Running, Shut Down, Restarting, or Terminated.  EC2 instances come in many different sizes, the smallest of which costs 8.5 cents / compute hour (Essentially $61.20 / month for a constant duty machine based on 24 hrs / day for 30 days).  Reserved instances may also be purchased for a lower cost.  This reduces the hourly rate to roughly 3-3.5 cents / compute hour with a $300 up front commitment.  Most of the lower instances will be created with a 15 GB hard drive by default.  You can increase or decrease the size of the main volume during setup.
     
  • Spot Instances
    A spot instance is an on demand instance for which you pay minimally based on the fact that they are limited to availability. 
     
  • AMIs
    An AMI or Amazon Machine Instance is a bundled image which can be selected under the instance panel for deployment.  If you have ever used VMWare, think of this like a virtual machine which is in the off state, except you can start up many instances of a single AMI.
     
  • Bundle Tasks
    This panel does not get used as much as it used to.  When you are creating a custom AMI of an image with a local storage drive built into it, this panel will show you if you have a running bundle task against that instance.
     
  • Volumes
    Over the past year, Amazon has move away from using local storage within the instance.  Now they allow you to use an elastic block store "EBS" volume and attach it to an AMI.  You can also attach additional EBS volumes to an instance for additional storage.  A volume though can only be attached to a single instance at once.
     
  •  Snapshots
    A snapshot is similar to snapshotting within VMWare.  It allows you to choose a moment in time and backup the entire contents of a volume.  This can be used to run manual backups, but it is also a natural part of creating a custom AMI of a running instance.  During the snapshot process for custom AMI's the instance is shut down, the hard drive is snapshotted and bundled with the bootstrap data required to start an instance.
     
  • Elastic IPs
    By default, instances are considered ephemeral. Restarting and bundling are the only two states through which your internal IP and external IP address will stay reserved to your instance.  If you terminate an instance, it's IP address is thrown back into a pool and you are assigned a new one.  If you don't want to lose your IP and be stuck updating DNS records (assuming you are using the server in a production environment), you can purchase an elastic IP which will ensure that you are always guaranteed the same IP...you even have the ability to assign it to a different AMI.
     
  • Security Groups
    By default, all ports are closed.  To get around this, you must create a security group which has all the appropriate ports opened so that you can access appropriate services on your server.  For example, a linux server should (at minimum) have port 22 open or whatever port you decide to run SSH on.  It would probably have port 80 open for serving up http requests.
     
  • Key Pairs
    A keypair is used during the bootstrapping of your instance.  When it starts up, password authentication will always be turned off by default.  This means that you need to have a key on file in the system so that you can use it to login to your instance once it is fully deployed.
     
  • Load Balancers
    One of the great features of AWS, is that it provides what Amazon calls an "Elastic Load Balancer".  ELB's are easy to set up and work similar to traditional load balancers.  There are custom health checks which can be altered on the fly and they allow you to specify a page to access which will determine if the load balance server is healthy.  I usually create an index.html page which just returns a 200 OK message to the Load Balancer.  Once an instance stops returning a response when the page is pinged, it will simply remove the instance from the load balancer queue.
     

Step 3
Now that you have a basic understanding of AWS, you can set up your first instanceTry not to get too excited, but it is cool.  You will choose a base installation image.  Make sure you choose a good base image...once you have it up and running, you probably don't want to start from scratch again ;).  I highly recommend the images produced by Eric Hammond of Alestic.  He makes great base images which are lean, so you can build them out however you want. 

Once you have chosen the image, the Amazon EC2 interface has a wizard to lead you through the process of launching for your first EC2 image.  Once you start the launch process, it will take 2-3 minutes to provision the server.  You can monitor the progress from the Amazon Web Services admin panel.  For the initial connection, you will need to use the public IP assigned to your server along with the pem key that you created during your account signup process.

Step 4

Once you have your image built exactly the way you want, it is important to snapshot the Volume as a backup.  This will create a bundled instance.  During this process the system will go down for bundling.  Once finished, your server will restart and be ready for use.

Now that you have your initial server, now comes the fun part!  Unfortunately...I don't have time to write about it right now :).  Next time I will discuss the process and caveats to setting up an Amazon Elastic Load Balancer.  Stay tuned...

 

Comments

Garden Table Link Swap (not verified) says:

Hello there, I couldn't find any means to email you, and so I really hope that you read this comment. I own a website about garden tables, and wondered if you would like to exchange links with me. I have submitted my contact address if you would like to get in contact. Thanks.

Garden Table Link Swap (not verified) says:

Hi there, I couldn't see a means to email you, and so I really hope that you see this comment. I own a website about garden tables, and thought you would like to exchange links with me. I have submitted my email address if you would like to get in contact. Thanks.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

chris Burdick

While I am officially a PHP Developer and Systems Administrator for Purple, Rock, Scissors, I consider myself to be a jack-of-all-trades. I have done a little bit of everything and have a storehouse of useful (and some useless) knowledge to share with the world. It is part of being what I like to call an "NBG" or "Natural Born Geek". While 
I 
don’t 
look 
like 
a “stereotypical” 
geek, 
I
 have had
 a 
fascination
 with
 anything
 technical
 since 
the
 age
 of
 7,
 got
 into
 software 
development 
in
 high
 school,
 and
 later 
got 
into
 artificial 
intelligence/robotics
 in
 college. After 24 years of living in a town of 7,000 people (thats 7K not 70K) in Connecticut, it was time to move on to Orlando, my new home. It was a big change, but certainly worth it. When I'm not at work, I like to hit up theme parks, watch a little TV, play some video games, hang out with friends, or cook. Cooking is a side passion of mine, and I love to whip up a fresh dish instead of eating out all the time. Nothing beats a relaxing night in with friends with a good bottle of wine, a newly discovered recipe, and good music to bring it all together. What defines good music? Everyone is different, but I like a little of everything--from techno to indie to country to alternative rock to classical to jazz. No genre goes untouched in my collection.

my Favorites

KitchenAid 10 pc hard-anodized cookware set KitchenAid 10 pc hard-anodized cookware set

These are an awesome (and cheaper) alternative to Calphalon. They wear extremely well and you can always get a great deal on them via Amazon. The only thing that would sweeten the deal would be a 12” deep skillet.

Infiniti G37 Journey Sedan

So, while I enjoyed my Honda Civic Si...I truly missed having creature comforts. I finally took the plunge and went back into a luxury Sedan with a fully loaded 09 G37 Journey Sedan in Liquid Platinum. Call me crazy, but I like it when my car opens to my touch, responds to my voice and just seems to 'know me'. I call him HAL 9000 and he is my new toy :).

MacBook Pro 15

Although I have the older style, I love my MacBook. I honestly never thought I would say that, as I was a PC guy up until 9 months ago!

my Flickr

  • Happy Birthday Justin!!
  • Photo 5
  • Foosball Fights
  • Foosball Fights