Use AWS S3 vs Cloudfront

Question:

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.

Answer:

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

Leave a Reply