I remember reading somewhere that there was a serious pitfall to using Amazon S3 for hosting a static website. I forgot what it was though. To me, S3 seems like a perfect option. Super fast, super scalable, and pay as you go.

What are the negatives of using S3 to host a static website?

  • In short, the answers below do not state any good reasons to not use S3. The www redirect is now easy to resolve. – JohnAllen Jul 26 '16 at 21:11

I'm still shocked to read that people assume that Content Delivery Networks are expensive, most charge as little as 0.20c per a GB.

Serving static websites on CDNs is amazing - you get the performance of a dedicated server without actually paying for it, plus you have a server in all major regions around the world so effective its actually better than a dedicated server for speed and scalability.

There are a few major setbacks when hosting on CDNs, and these are:

No PHP files

PHP support (You'd need to use contact forms via Ajax to retrieve a contact.php from elsewhere, HTML methods suck – if you don't need a contact form, then (awesome!) for things like comments you can use Disqus, which is JavaScript.)

CNAME issues

Sadly most CDNs don't support non-www CNAMEs so you can't resolve the domain when someone forgets the www, not a major problem but there are ways around this. You setup a EC2 or shared hosting and you let it handle the non-www with a redirect. So whenever someone forgets the www it communicates with the server, then redirects to the CDN correctly. An alternative method is that you pick a CDN which supports this - I believe Limelight does, but Amazon and Rackspace do not. I've heard Limelight hosting the DNS and making edits manually on their system, I've never done this myself so I can't confirm they do or do not.

Content Updating

The other set back is that you need to purge the content or files that your editing, so say for example you make some additions to the index.html you'd need to either setup a short expire on the container or manually purge that file from the cache so it updates all over the world.

Summary

Hosting a static site on a CDN is fanstatic - I run a handful of static sites on CDN and they are fanstatic, I only use like 1-2GB on each site and I get bills for £0.24p for each site, which is cheaper than shared hosting, and gives you the performance of a dedicated server. If your going to setup a small VPS other than a EC2 for the redirect any VPS that is 128mb will do it. You can get a cheap one for like $1 a month. Just Google 128mb VPS or VPS under $5 a month - there's hundreds of companies doing low spec VPS for peanuts which will do the trick.

  • 1
    Cloudflare doesn't have issues with non-www cname. Plus the free tier is not bad either – elssar Jan 28 '13 at 1:52
  • Amazon has a dns service called Route 53 that could be used to route the tld to the www subdomain. – gang Aug 15 '14 at 9:47
  • Specifically AWS Route 53 has ALIAS records where you put in another host name (like you do with a CNAME), but the DNS server does the lookup periodically (seconds) and serves the record with the IP address (A record). – Stephen Ostermiller Jan 26 '16 at 21:27

The problem is in the "pay as you go" part.

If you get tons of traffic (ie: a DOS attack or a very popular blog post or file) you will PAY for it.

AFAIK there isn't still a feature to put a cap to what you pay. You can set billing alerts, but if your billing reaches your maximum budget the only option you have is to shut the site down or you will pay for all the traffic you get.

  • Something to think about: Heroku allows you to pay for only as much as you want, but you may end up losing some visitors who aren't able to access the site. AWS on the other hand lets you make sure you capture all the visitors, but you'll have to pay for it. Depending on whether you've set up ads/some other form of converting clicks to cash, your requirements for pay-as-you-go may be different; a small cool web app for example, may benefit from Heroku (or a similar service). – abhi divekar Jan 5 '17 at 5:35

S3 isn't meant to be the ONLY tool from AWS for static website hosting. The recommended approach is to put CloudFront in front of the S3 instance so that CloudFront can handle caching. I believe this will also eliminate your issue with paying a bunch for an increase of traffic since CloudFront will use it's cache to serve the files and not hit S3. Of course, you're having to pay for CloudFront, but the cost will be less (I think).

Here is an article about this adding CloudFront to your S3 site:

http://docs.aws.amazon.com/gettingstarted/latest/swh/getting-started-create-cfdist.html

It's actually a bit overpriced in terms of bandwidth. They also had, until very recently, an issue were you couldn't map both your @ and your www A record to your site (so you either had mydomain.com accessible, or www.mydomain.com accessible). This however was fixed in a very recent update.

Personally, I think they're a bit overpriced, and you are lacking a lot of nice features (redirects, htaccess, etc). S3 does work well for hosting large files and images though.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.