CDN Take 2: Amazon Cloudfront

Back on March 11 I ended the Content Distribution Network experiment with Cloudflare.  However, the reason I entered into that experiment still existed – performance of the website, and fear of having my Hostgator shared hosting account suspended for overuse (“abuse” is what they call it; but they don’t provide a way of predicting when we’re getting close to that “abuse” level.)  Today Twitter friend Steve Creek had his Hostgator shared hosting account suspended for this very reason – caused by the site’s popularity.  Twitter friend Adam Jack had previously mentioned that he was looking at Amazon’s Cloudfront service, so I had taken a look at it and it seemed usable.  I made some changes today.

Today I moved most of the thumbnails for USWildflowers.com over to Cloudfront.  It was more complicated than I had hoped since I’m not up to speed technically to create the configuration using XML API calls, and it will be a bit of a pain to maintain until Amazon changes the administrative console to support external website sources, and it will cost some money (hopefully not much, USWildflowers.com is barely breaking even.)  However, Amazon’s web service will hopefully be reliable and improve performance.

The reason I chose the thumbnails is that I made an assumption that it wouldn’t be a bandwidth issue that would get my account suspended but rather a cpu utilization issue.  The “hit/file lookup/response” overhead is close to the same regardless of file size, so the smaller thumbnails should reduce CPU utilization almost as much an equivalent number of full size images, and since Amazon charges by the gigabyte transferred for Cloudfront, distributing the thumbnails rather than the full size images will hopefully be less expensive.

One thing that I had done several days ago that will also hopefully help some was to set cache control metadata tags on the images served up from USWildflowers.com so that browsers and network caching mechanisms will cache those images for up to four hours.

Incidentally, Google Webmasters statistics indicate that performance has improved recently over what it had been while on Cloudflare, so maybe the cache control metadata changes were having their intended effect.

Update 04/01/2011:  Amazon Cloudfront handled almost 100,000 http requests for me in the 5+ days since moving the thumbnails over there, for a total of almost 2 gigabytes.  The Hostgator stats show the significant drop in hits as well.  During the period from when I left Cloudflare to moving onto Cloudfront, Hostgator stats showed an average of about 20 hits per page view.  Since moving onto Cloudfront, the average is about 9 hits per page.  While these hits are not the high-cpu ones in WordPress or the code hitting the database, eliminating the overhead of 10+ http requests per page has got to help; hopefully enough to avoid the dreaded “abuse” suspension.

Note that the average hits per page were even lower on Cloudflare than on Cloudfront (by about 1 hit per page.)  Presumably this is because Cloudflare was caching all the images, not just the thumbnails.  My feel is that the performance is better on Cloudfront than on Cloudflare, but I also feel more confident that with Amazon’s resources (and the simplified model; not a true “cache”, but rather a web server for static content) the results will be more reliable than with the *free*, beta Cloudflare product.

Speaking of economics – Cloudflare was free; Amazon’s handling of those 100,000 request cost me 44 cents.  Amazon allows entry to the paid service at a low price point, based on utilization.  Cloudflare provides a paid service as well, but the lowest cost is $20 per month, which was well beyond the reach of USWildflowers.com’s budget.   Cloudflare also provides some other services beyond the caching (primarily security functions) but those were not within the target objectives for this effort.

Update 09/24/2014: I’ve now been on Amazon Cloudfront for over three years. It has proven reliable; I’ve heard reports of some failures but never noticed it myself, perhaps because I now have the caching set for 30 days on the thumbnails. Costs for the biggest months became an issue – over $35 in the highest month. To reduce costs, I changed the top 400 thumbnails to a different compression, significantly reducing image quality (but this IS a thumbnail; as long as it is recognizable quality isn’t key) but also SIGNIFICANTLY reducing size – thumbnails went from averaging around 40kbytes each to around 4kbytes each. Comparison – 10.2 million thumbnail hits in May 2013 cost $35; in May 2014 the cost was $19.47 for 13.4 million hits. I also added DNS services at Amazon in late 2013; May cost for DNS was 70 cents.

4 thoughts on “CDN Take 2: Amazon Cloudfront

  1. Adam Jack

    How is this experiment going?

    Sorry you had to upload manually. I think CloudFront works best for folks who already have their data in Amazon S3 ‘cos then it is just add the work cloud front into the URL and you are done. Sorry, guess I figured that out a bit late. :\

    BTW: This is a neat new tool from Google:

    https://developers.google.com/speed/pagespeed/insights/?url=uswildflowers.com [Ed note: URL updated 07/28/2016]

    it concurs that your browse cache settings are mainly working. The rest of the things it mentions are likely not worth much time, but at least it does let you know your looking good to Google.

    Question: Do you use Google Webmasters tools? That has a neat “speed chart” in it that will even give you some history.

    http://www.google.com/webmasters/

    Last bit of geekery. Do you have a sitemap registered w/ Google/Bing? If you do, you might save some bandwidth by telling it that things (e.g. older postings) don’t change a lot, so don’t scan too often.

    Just some random idea. Good luck.

    Reply
    1. gcw Post author

      Thanks for the tips, Adam. I am using Google Webmasters; have been using that to get a feel for response time, and also use it to find broken links. Amazon Cloudfront is doing its job; it’s handled >120k hits this month, and 2.5gigabytes of bandwidth.

      Reply
  2. Jan Husdal

    Interesting post. I’ve been playing around with CloudFront versus CloudFlare myself, but my experiment turned out quite differently:

    CloudFlare beats CloudFront

    Basically, CloudFront only changed my page speed a tiny inkling, whereas CloudFlare made a huge difference. And since I was paying upward of $10/month for CloudFront, it’s obvious which service I give thumbs up.

    Anyway, how have you been doing since you wrote this?

    Reply
    1. gcw Post author

      Thanks for commenting, Jan. No change in position for me. Cloudflare (free version) is definitely less expensive than Cloudfront. However, since the primary cost of Cloudfront is bandwidth, and I’m only using Cloudfront for static thumbnail images, my cost has been relatively low; this month it will probably be a bit over $6.

      My “feeling” is that performance is slightly better with Cloudfront, but if it is, it isn’t a lot different. The big difference is in reliability. I haven’t noticed an outage at Cloudfront; there were a few with Cloudflare, one of which was prolonged. Watching the Cloudflare Twitter traffic, I have not been alone in experiencing outages.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *