How I served 100k users without breaking the server or a dollar bill
blogging.alastair.is
blogging.alastair.is
I have a tutorial on using Jekyll, the static site generator that I'm sure a lot of you are familiar with: http://learn.andrewmunsell.com/learn/jekyll-by-example/
I also go over how to use Amazon S3 and Dropbox for hosting, since Jekyll is pretty versatile (it just spits out HTML).
ismytwitterpasswordsecure.com resolves to 192.31.186.144, which is some unknown HTTP server at Namecheap, meanwhile www.ismytwitterpasswordsecure.com resolves to a CNAME that causes the browser to directly hit Amazon.
As mentioned by another commenter, the "proper" solution to this which doesn't depend on Namecheap's unknown quality HTTP server serving up redirects, is to use Amazon's DNS hosting and their proprietary aliasing solution: http://aws.typepad.com/aws/2012/12/root-domain-website-hosti...
(side note: this blog post isn't hosted on S3. If it goes down, I will eat a big slice of humble pie)
(side note #2: the title has since changed to make this post make no sense whatsoever)
Amazon products create insta-fear in me. It seems very overwhelming. I usually just fall back on DigitalOcean/Linode whenever I consider using S3.
But S3 is simple. Big buckets, tons of files in flat order. No magic involved. I've been very happy with it and you can still take your computing needs elsewhere.
That guy was reporting a 2% error rate from one S3 server, but there has been additional discussion on that thread which suggests that error rate is an aberration. Personally, I have no hard data, just the anecdote that when I started developing with S3 I wasn't using retries and that became a problem after approximately a few thousand queries. Unfortunately I've never seen Amazon say what error rate to expect, just that you should be sure to retry on error. I think I'll start logging how often I need to retry so I can get some hard data.
Keep in mind that when you're hosting a site on S3, you have to multiply the error rate by the number of resources you're serving from S3 to get the probability an individual user will have problems. www.ismytwitterpasswordsecure.com serves 4 resources from S3. Assuming a 0.1% error rate, 400 out of the 100,000 users would have had problems.
As another commenter has suggested, you can serve from Cloudfront instead of directly from S3. That will significantly reduce the number of hits which are made to S3.
http://docs.aws.amazon.com/gettingstarted/latest/swh/website...
What do most folks do in this situation? Put CloudFlare or Fastly in front of S3?
Create it as an API that's reachable through JSONP or (better) CORS. It won't stop you having scaling issues, but it'll help to reduce the number of requests hammering your database. I've recently spent an unhealthy amount of time setting up Varnish to cache dynamic content, so a post on that topic will be coming down the pipeline soon.
The process of creating a specific 'www.example.com' bucket just to do the redirects seems to break my analytics software (Piwik) and as a result, it doesn't track referrers properly. That is, anyone who visits by a www.example.com link will have no referrer and just say "Direct Entry" since they hit the redirect then arrived at example.com
http://aws.typepad.com/aws/2012/12/root-domain-website-hosti...
(and plus, there's redirection)
edit: There are consequences relating to mx records, such as if you want mail service on the domain. From a comment:
> Just be careful here with doing CNAMEs on root domains. Things like email will break because the MX records are no longer visible behind the CNAME. Gmail for example won't send emails to domains with a CNAME as root.
Related article: NPR's apps team had a nice post about how most of their projects are S3 hosted flat files: http://blog.apps.npr.org/2013/02/14/app-template-redux.html
Edit: Amazon has actually clarified this point in the comments of the article as well -
‘You're completely right about CNAMEs at the domain apex, they do tend to break MX and NS records. When this feature is used with Route 53 ALIAS records, no CNAME will be present - behind the scenes the ALIAS record links directly to the S3 "A" record data.’
I'm aware of billing alerts, and they're quite useful. But I am really paranoid one of my properties is going to get linked to on Reddit, Digg, or similar and then I'll wake up to a $5K bill which I can ill afford.
I'm not saying I agree, just making an observation.