Last updated: April 17, 2019
Amazon S3 vs. Cloudfront – Which to Use?
From database hosting to servers hosted in the cloud, Amazon offers a wide variety of Web services. However, most webmasters find themselves considering just one of the two: Amazon Simple Storage Service (S3) or Amazon Cloudfront. While Cloudfront is actually built on top of Amazon S3, these two services have very different purposes and should not be used interchangeably.
Which solution is better for your your site? It depends on your goals, but knowing which service is right for you can help you avoid potentially costly mistakes.
Big ‘n’ Thrifty: Using Amazon S3
Amazon S3 is similar to many other hosting solutions, storing your files at a central location for access. It generally offers less expensive bandwidth and storage than traditional shared or virtual private server (VPS) hosting accounts, as well as greater reliability and faster access to your data.
Amazon S3 is ideal when low cost of bandwidth and storage is more critical than speed of access. Some good examples would include non-public-facing elements of your site (like storage and access to backups) and large downloads (like podcasts, software, and games).
Small ‘n’ Speedy: Using Cloudfront
Cloudfront, on the other hand, is all about speed of access. Whenever you upgrade an S3 bucket to Cloudfront, your data is immediately pushed out to their edge locations around the world. This gives users much faster access to the data, but this speed comes at a cost. Each edge location has an associated cost in addition to the regular Amazon S3 fees. Very active or very large files can generate significant fees.
Smaller files are most noticeable when they fail to download quickly, especially when that failure prevents a website from loading properly. Shaving milliseconds off the loading time of site images can dramatically affect the overall loading time of the site. Using Cloudfront makes the most sense with small- to moderately-sized files that carry minimal increased costs but provide a major boost in performance with increased speed.
The rules for using these services are far from absolute. Twitter, for example, uses Amazon S3 instead of Cloudfront for hosting avatar and other image files. S3 provides adequate speed, and Cloudfront would have been cost-prohibitive with such a large number of files. Consequently, Twitter relied on Amazon S3 for some time, although it has since switched to Akamai for its avatar hosting.
Both tools have their place. Amazon continues to offer both (and has even expanded S3 by offering Reduced Redundancy Storage), but choosing the wrong solution for your business needs can compromise user experience and create needless expense. Using the right tool for the job can help you keep things speedy and user-friendly—without breaking the bank.