Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use AWS S3 vs Cloudfront

Since heroku file system is ephemeral , I am planning on using AWS for static assets for my django project on heroku

I am seeing two conflicting articles one which advises on using AWS S3. This one says to use S3

https://devcenter.heroku.com/articles/s3

While another one below says, S3 has disadvantages and to use Cloudfront CDN instead

https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn

Many developers make use of Amazon’s S3 service for serving static assets that have been uploaded previously, either manually or by some form of build process. Whilst this works, this is not recommended as S3 was designed as a file storage service and not for optimal delivery of files under load. Therefore, serving static assets from S3 is not recommended.

like image 361
dowjones123 Avatar asked Aug 21 '14 09:08

dowjones123


2 Answers

Amazon CloudFront is a Content Delivery Network (CDN) that integrates with other Amazon Web Services like S3 that give us an easy way to distribute content to end users with low latency, high data transfer speeds.

CloudFront makes your static files available from data centers around the world (called edge locations). When a visitor requests a file from your website, he or she is invisibly redirected to a copy of the file at the nearest edge location (Now AWS has around 35 edge locations spread across the world), which results in faster download times than if the visitor had accessed the content from S3 bucket located in a particular region.

So if your user base is spread across the world its a better option to use CloudFront else if your users are localized you would not find much difference using CloudFront than S3 (but in this case you need to choose right location for your your S3 bucket: US East, US West, Asia Pacific, EU, South America etc)

Comparative features of Amazon S3 and CloudFront

like image 166
Tapaswi Panda Avatar answered Oct 01 '22 12:10

Tapaswi Panda


My recommendation is to use CloudFront on top of Whitenoise. You will be serving the static assets directly from your Heroku app, but CloudFront as the CDN will take over once you reach scale.

Whitenoise radically simplifies build processes and the need to use convoluted caching headers.

Read http://whitenoise.evans.io/en/latest/ for the full manifesto.

(Note that Whitenoise is relevant only for static assets bundled with your app, not for user-uploaded files, which still require S3 for proper storage. You'd still want to use CF though.)

like image 38
Yuval Adam Avatar answered Oct 01 '22 12:10

Yuval Adam