Blogger social buttons

Monday, 23 April 2012

How to host your site on S3 for $0.12/month

We have been hosting our website on AWS S3 since we launched in February 2012. We were surprised to see that it's only costing us $0.12 per month, or as we say here in Scotland it's "cheap as chips".


This is our "marketing site" where we pitch PlanForCloud, host our docs and other static stuff. We use Rails for our web app and host that with Heroku, so we also wanted to make our static site with Rails. This is partly because we want to use the same Rails HTML templating system, but also to have the option of adding dynamic content into our site in the future. But we didn't want to pay an extra $35 for an extra Heroku process to run our site, so we chose AWS S3. Here's how you can do the same:
  1. Create an S3 bucket and configure your DNS records, see Chris O'Sullivan's blog on how to do this.
  2. Add the high_voltage Ruby gem to your Rails app to help you make static pages. There are other similar gems out there but we chose this one as it's very simple to use. We also use the jquery-rails, sass-rails, coffee-rails and uglifier gems to compile our JS/CSS assets into a single file. This helps us further reduce our costs (less file read/write requests) and makes the site load faster.
  3. Write a simple rake task to push the site to S3 from your machine so you don't have to login to the AWS Management Console all the time. We use the wget and s3cmd command-line tools to help with this. The trick is to run Rails, use wget to download the static pages from your localhost, then upload them to S3 using s3cmd.
It turns out that we're not alone in doing this, Amazon CTO Werner Vogels is also doing this for his blog. Log in as a guest or signup at PlanForCloud if you're like us and like to forecast costs on prospective deployments.

UPDATE 05 October 2012:
Amazon S3 has now added support for website redirects, meaning that if you want to redirect from an old page to a new page (e.g. from www.PlanForCloud.com/old to www.PlanForCloud.com/new), then you can enable a 301 redirect (permanent redirect - good for Search Engine Optimisation) through the AWS management console or API. Read more here: Amazon S3 - Support for Website Redirects


UPDATE 28 December 2012:
Amazon has added support for root domain sites being hosted on S3: "Visitors to your website can now easily and reliably access your site from their browser without specifying “www” in the web address (e.g. “example.com”)." More information here


--Ali

Friday, 20 April 2012

The cost of getting popular

One of the key benefits of using the cloud is elasticity and AWS naming their main offering Elastic Compute Cloud (EC2) signifies this. Most startups deploy their systems on the cloud nowadays, and they have a freemium business model, so the paid customers need to bring in enough cash to cover the cost of the free customers. But how much do those free users cost to host? Animoto's famous Facebook scale-up, where they went from 25,000 users to 250,000 users in three days highlights this issue, and indeed most of the comments on the AWS blog about this were discussing costs. Top industry analysts like James Staten also acknowledge that budgeting for clouds won't be easy as use patterns change over time.

As part of PlanForCloud, we've developed a unique feature, called patterns, to enable you to see the effects of elasticity on your costs. Patterns describe how a baseline changes over time. For example, on average, your deployment might need 5 web servers every month (the baseline). However, during the busy shopping season, you might need to double this baseline. Or you might want to see the effects of adding 3 servers to your baseline every month as you grow and get more popular. These changes can all be described using elasticity patterns.

In PlanForCloud you can use elasticity patterns to model cloud growth
Creating patterns in PlanForCloud
Each pattern can consist of many rules that describe it. There are two types of rules that you can create:
  • Permanent Rules: changes made by permanent rules persist, hence they change the baseline after they've been applied. Permanent rules are useful when describing a pattern that sets a new baseline. For example, you might create a storage unit that uses 100GB per-month, and this value needs to be increased by 5GB every month. You can create a single permanent rule to describe this pattern (every month +5), rather than create individual rules that set the baseline every month (January: 100GB, February: 105GB, March: 110GB...).
  • Temporary Rules: changes made by temporary rules only apply for the duration of the rule, hence the baseline is changed back to its original value once the rule has been applied. Temporary rules are useful when describing a pattern that is one-off. For example, you might create 5 web servers to serve your users every month, but you need to double this to handle a peak that your site gets during the summer. You can create a single temporary rule to describe this pattern (jun-aug *2). This means that the number of servers will be set to 10 in June, July and August, and go back to 5 in September.
Cloud patterns - permanent and temporary growth - PlanForCloud

You can create rules using our simple UI:
PlanForCloud growth patterns and rules

The following table provides examples of the various values you can enter when creating rules.
PlanForCloud growth rule types

Finally, the following charts show the effect of the different operations that can be used when creating rules. Overall we feel that elasticity patterns are a very useful feature that let you do what-if analysis on your costs, and help you plan your cash-flow when you're just starting out. Why don't you try this feature and let us know what you think.

PlanForCloud example cloud growth patterns and elasticity