Alfa Jango Blog Engineering, Software, and Entrepreneurship

Posts Tagged ‘Amazon S3’

Caching, Zipping, and (Amazon CloudFront) CDN For A Rails App

Friday, June 18th, 2010

This is Article #4 of a 4-part series. For a good primer, check out the first two articles listed below. For the reasoning and analysis behind the “Recommended” option in this article, check out Part 3, How to Combine GZip + CDN for Fastest Page Loads. Otherwise, jump right in!

  • The Importance of Page Load Speed
  • Improve Page Load Speed (by 80%) by Improving Component Load Speed
  • How to Combine GZip + CDN for Fastest Page Loads
  • Caching, Zipping, and (Amazon CloudFront) CDN For A Rails App
    • Prerequisites
      1. Cached stylesheets and javascripts
      2. Creating an Amazon AWS Account
    • Setup S3 Buckets
    • Setup CloudFront Distributions
    • Create CNAME records (optional)
    • Install Rails S3 Synch Plugin
      1. Installing AWS-S3 Gem
      2. Configure S3 Synch Plugin
      3. Add S3 Synch to Deployment
    • Option A: Compressible Assets from App Server, Images from CloudFront (recommended)
      1. Configure Rails Asset Host
      2. Create A-name Record
      3. Configure Apache
    • Option B: Serve Everything from CloudFront (easier, but not recommended)
      1. Configure Rails Asset Host
      2. Pre-compile Cached Stylesheet and Javascript File
    • Conclusion

In this article, we’re going to speed up our Rails application by up to 75%, simply by optimizing our Rails asset host. We’re going to serve our components (stylesheets, javascripts, images, etc.) from a combination of our app’s server and Amazon CloudFront (Option A, recommended), or entirely from CloudFront (Option B – easier).

The best option for you may depend on your specific needs, but I’ll cover both processes below. For a an in-depth analysis of why Option A is recommended over Option B, see the last article in this series, How to Combine GZip + CDN for Fastest Page Loads.

(more…)

How to Combine GZip + CDN for Fastest Page Loads

Friday, June 11th, 2010

This is Article #3 of a 4-part series. For a good primer, check out the first two articles listed below. Otherwise, jump right in!

In my last post, I discussed the three techniques used to improve asset load speed. In this post, I will discuss how to combine the use of GZipping and a Content Delivery Network (CDN) for the fastest possible page loads.

Pitfall of Amazon S3 + CloudFront

Everyone’s favorite CDN these days is Amazon’s CloudFront service, which serves files directly from Amazon’s scalable “simple storage system”, Amazon S3. It is very easy to work with, has widespread support in Ruby gems and plugins (and countless other libraries), and is very inexpensive with it’s pay-as-you-go billing.

However, there is one large pitfall to using Amazon S3 + CloudFront, and that is that neither S3 nor CloudFront support GZip detecting and encoding. It would seem that we need to now decide whether we’ll do without GZipping or using a CDN. Not so! There is another way.

(more…)