Thursday, February 24, 2011

Amazon S3 offers complete Website Hosting

Since Amazon launched its storage service simple storage service (S3) cloud in 2006, people are using it to support Web sites hosted with other service providers.

S3 was initially used to host large files like movies, in which case the S3 is both cheaper and faster than most Web hosting providers. Other files, such as hosting images was initially challenging due to latency problems (i.e. a delay between when a browser requests a file that receives it). This has been addressed when S3 introduced additional datacenters throughout the world and better load balancing.

However, until now has been impossible to host entire Web sites to S3, because there was no way to define the root and the error documents within an S3 "bucket" (a bucket is the name given to individual storage configurations).

In other words, there was no way to configure S3 to serve index.HTML when visitors were directed to an S3 bucket and no way to serve something like error .html, if something went wrong.

This has now changed. Error documents and root can be defined for each segment, although there are a handful of important notices.

First, since S3 storage is just stupid, hosts a whole site is possible only for static content entirely--i.e. nothing more than an HTML file, images and so on. Someone who wants to use PHP or similar will be required to use Amazon's Elastic Compute Cloud (EC2) or a standard hosting provider. This means that couldn't fit something like a WordPress blog to S3, for example.

Secondly, you cannot host a domain root to S3 because S3 is accessible only via redirection CNAME DNS record (S3 has no IP address static endpoint, so that it cannot be configured for the record-). In other words, host www.example.com is possible, but not example.com. A separate hosting service configured for DNS-records would direct visitors arriving at example.com to www.example.com. (Incidentally, many experts consider adding www as a CNAME record to be bad practice, although it works fine.)

Setting up full website hosting with S3 is easy. Start visiting the S3 Control Panel and create a new bucket in your AWS, named the Web address that will direct us. For example, should I hope visitors www.keirthomas.com to be redirected to a bucket, name it www.keirthomas.com.

Then upload all files of your website using the Upload button on the console or via S3, a separate client application, if you use one. Don't forget to set all files as accessible to the public, you can perform from the Upload window.

Next, right click the new bucket, listed to the left of the console and select Properties. In the new Panel at the bottom of the window, click the Web site tab and make sure that Enabled is checked, first type the filename of your documents and the index. Note that you cannot specify 4xx specific documents, such as 404, 403, and so on; all errors should be directed to the error page. Click the Save button when done.

Configuring S3 to host an entire Web site is as easy as clicking a checkbox. (Click for full image).Note the address that is listed next to the Endpoint, which is under the names of document index and the error in the Panel itself. Now head over to the configuration of your domain registrar (s) of the Panel and configures a new CNAME record for www, specifying the endpoint address of S3 (remove the http://prefix from the endpoint address, and any trailing slash at the end).

How it's done configuring CNAME varies from vendor to vendor. You will probably need to delete the record-for www, too.

And you're done! Once the DNS changes have propagated, which could take a couple of hours, your visitors will be directed straight to the S3 bucket containing your site and you will see the file index.html.

As a further step, it's a good idea to choose the address for a-records (i.e. the address without the www prefix) a simple Web hosting service where you can set an automatic redirection to www.

If yours is a high traffic site, might also make sense to use Amazon's CloudFront service to ensure traffic is directed to the nearest server, that will avoid any latency problems. This will add to the cost, though.

As well as using S3 compares in terms of costs for a standard provider? I use Dreamhost Web hosting basic package for sites that I run, which costs $ 119 per year and offers storage and unlimited bandwidth (while sharing a server with others, that may limit the speed at which my site is served).

However, unlike S3, the price of Dreamhost also includes PHP, databases, and various useful extras such as one-click installs of popular software site.

A static site that runs by Dreamhost sees about 300 visitors a day and offers a 2 MB file for download. From the configuration panel of Dreamhost, I see that the site burns through about 350 MB of bandwidth per day, including weekends.

Using a quick rough calculation, I see that is 10.65 GB per month, that if served via S3 would cost me nothing if I signed up for the free use of Amazon Web Services. This allows up to 15 GB of data transfer per month, although I might run into a couple of dollars throughout the year due to GET requests. Free usage level allows you to GET 20,000 requests per month, and my 300 daily visitors typically visit many pages and download many images, each of which involves a GET separated.

While a comparison with Dreamhost is simply unfair because Dreamhost offers much more than simple storage to S3, the price is very interesting if you are paying a fee for each GB or TB with your existing provider. Plus, S3 will be always fast and will never run out of storage space.

Keir Thomas has made known his opinion on matters of calculation from the last century and more recently has written several best-selling books. You can read more about him at http://keirthomas.com. His Twitter feed is @ keirthomas.



No comments:

Post a Comment