adam121 - Fotolia
Getting data into cloud storage is a key ingredient of any online architecture. Planning how you will access that data is even more important. Although CloudFront and S3 appear to be similar AWS storage services, they function very differently.
Amazon Web Services (AWS) Simple Storage Service (S3) provides virtual hard drives in the form of buckets containing objects (files). Amazon CloudFront is a Web service that improves the delivery of select files from global AWS edge servers to its customers. Any type of data in any format can be stored in S3, including backups, static website files, images, videos, Amazon Machine Images, Elastic Block Storage and CloudTrail log files, among others. S3 objects range in size from 1 byte to 5 GB.
Amazon CloudFront is a content delivery network that replicates data across AWS’s 52 edge servers, which are located in major cities around the world. This places content closest to end users and delivers low latency and high data transfer speeds. CloudFront files have a maximum size limit of 20 GB.
Files in S3 and CloudFront both receive a unique URL, but there are several important differences.
Cloud admins can use S3 to deliver content at lower speeds to end users, but S3 is better equipped for use as an AWS storage repository where individual files are infrequently accessed. CloudFront is optimized to deliver frequently accessed static content such as websites, streaming videos, e-books and other Web-based content. CloudFront also eliminates the need to scale your Amazon Elastic Compute Cloud (EC2) instances up or down from traffic spikes if the frequently accessed content causing the traffic is replicated in the service. This offers a potential cost savings.
Files uploaded into an S3 bucket immediately receive a unique URL. With CloudFront, you need to register an origin server containing the content you want to replicate -- static or dynamic -- across edge servers. An origin server can be an EC2 instance, an elastic load balancer, an S3 bucket or any non-AWS server. There is no need to redeploy non-AWS servers into an EC2 to use CloudFront. AWS CloudFront fetches the content from the origin and performs replication.
Both CloudFront and S3 support SSL and DNS CNAME aliases; however, S3 allows only one CNAME assignment whereas CloudFront allows up to 10.
Setup and pricing for S3 and Amazon CloudFront
AWS S3 and CloudFront are easy to set up. First, sign up for the service using the AWS control panel and start configuring. For S3, create a bucket and start uploading files.
To set up Amazon CloudFront, create a distribution name that will be used to replicate content, such as mycontent.cloudfront.net. Insert this domain name into the website for the content you want to replicate. Consider creating a CNAME alias that points to the Amazon CloudFront distribution name.
For example, register an Amazon S3 bucket named mybucket.s3.amazonaws.com as the origin for all static content and an Amazon EC2 instance named mywebsite.com, which could contain static or dynamic content. Replace website references to content with the distribution domain name assigned to these origin servers as follows: mywebsite.com/mybigpicture.jpg becomes mycontent.cloudfront.net/mybigpicture.jpg. The file mybigpicture.jpg will be replicated. Each request made to mycontent.cloudfront.net (or to the CNAME you set up) is routed to the edge server with the lowest latency and delivered with the highest performance.
S3 pricing is based on GB stored per month, data transfer out and http(s) requests. CloudFront pricing is based on data transfer to the Internet or origin site, and http requests. Both AWS storage options offer regional pricing differences. To get started, you can take advantage of 5 GB of free storage space in S3 and CloudFront's 50 GB of data transfer out, along with 2 million free HTTP or HTTPS requests under the free usage tier plan.
About the author:
Russ Vanderpool, MSCS and MBA, is a technologist interested in using cloud technology to deliver solutions, identify new businesses and help companies better serve customers. He has hands-on experience as an architect/developer and a business adviser across the finance, energy, education, technology and nonprofit sectors. Russ has architected and built a cloud infrastructure for a green tech company and while working for Japan's largest systems integration firm, he developed proprietary object-oriented database visualization software for that market.