Skip to content

Amazon EC2

Amazon CloudFront – A Guide To Setup CloudFront To Work With S3

Suppose you are running a high traffic blog or website and you came across the following issues:

  • Sluggish Content Serving:  Content including the downloaded files, images, HTMLs is serving at a very slow speed particularly during traffic hike.
  • Paid And Idle: Your web hosting cost is very high as compared to what you are getting in return. This means, you have probably chosen a web host package of 50 GB web space and 1 Tb Band width but you using barely half of them.
  • Messy Files/Folders: The web account is in a messy condition. The downloadable files and folders are not organized in a proper way.

All these problems can be solved easily with Amazon CloudFront. CloudFront is launched by Amazon and is powered through cloud computing technology. By using Amazon S3 as storage, Cloud Front serves on the top of buckets and helps in delivering contents at a very high speed.

If you have already opted for Amazon S3 to serve files for the websites, CloudFront is really something to be checked out.

Here is a small guide to set up CloudFront for serving web files:

  1. The very first and foremost step: Get Amazon S3 account and sign up for Amazon CloudFront service. Make sure that this service is activated through your email.
  2. Create Distribution: Applications used for managing Amazon S3 bucket might differ but you can use a free tool known as S3 Firefox, which is a file manager that supports CloudFront. Connect to our account using S3 Firefox, right click on the name of the bucket (Assuming files and folders inside can be accessed using web) and then choose Manage Distributions.

Distribution is a type of unique URL that you can use for file referencing. You will be able to get a better picture once it is created. Click on create distribution for creating first distribution for bucket. Once you create it, you will notice a new domain name ####.cloudfront.net created for you.  The status will be turned to Deployed from InProgress once you are done with it. You can also use the refresh button for updating the status.

Your assets can now be accessed with the URL:

http://media02.yourwebsite.com/folder1/fileA.jpg

http://####.cloudfront.net/folder1/imageA.jpg

The secondURL is cloud powered and way faster to serve your files.

  1. Create CNAME: Distribution URL begins with http://####.cloudfront.net/ and there is no way to decide what goes prior to .cloudfront.net. However, in order to make the URL simple, easy and nice to remember, we can use a CNAME for mapping this URL to whatever you desire. This needs access to web hosting panels.

In this example, you can know how to map:

  • http://####.cloudfront.net/ to
  • http://media01 .yourwebsite.com/

If you are not familiar with CNAMES, it is suggested that you ask your web host provider to do it for you. You will learn something quite similar to this one, with your own distribution URL. This can take one day to broadcast, but in the mean time you can fill up the CNAME in S3 Firefox. Once it is propagated effectively (you can test it by pinging the URL), you can serve the files by using http://media01.yourwebsite .com/.

  1. Performance Comparison: We all have an idea about the efficiency and rapidness of Amazon S3 serve file, but you can check it by loading content as well as images under the different hosting of CloudFront. It will give you a clear idea of the time saved in the whole process. In this way, you can also manage your files in the best possible manner. So set up your CloudFront today with S3 to enjoy a wide range of benefits.
Be Sociable, Share!
    The following two tabs change content below.
    Kaylee is the person that makes the world 'go-round' here at codingthis.com. She is not only our resident Systems Administrator but also our publishing coordinator and even an occasional author. Kaylee has been with codingthis.com since 2013.

    Latest posts by Kaylee Pierce (see all)