When to use Amazon Cloudfront or S3

前端 未结 10 655
鱼传尺愫
鱼传尺愫 2020-12-12 08:43

Are there use cases that lend themselves better to Amazon cloudfront over s3 or the other way around? I\'m trying to understand the difference between the 2 through examples

相关标签:
10条回答
  • 2020-12-12 08:59

    As first i would like to explain that Amazon S3 is the cloud Storage and Cloud Front is the content delivery network (CDN).

    So you can use to store the files on S3 and can create the distribution to serve the content over the internet. As well as you can create distribution for the specific regions.

    0 讨论(0)
  • 2020-12-12 09:00

    Amazon S3 is designed for large-capacity, low-cost file storage in one specific geographical region.* The storage and bandwidth costs are quite low.

    Amazon CloudFront is a Content Delivery Network (CDN) which proxies and caches web data at edge locations as close to users as possible.

    When end users request an object using this domain name, they are automatically routed to the nearest edge location for high performance delivery of your content. (Amazon)

    The data served by CloudFront may or may not come from S3. Since it is more optimized for delivery speed, the bandwidth costs a little more.

    If your user base is localized, you won't see too much difference working with S3 or CloudFront (but you have to choose the right location for your S3 bucket: US, EU, APAC). If your user base is spread globally and speed is important, CloudFront may be a better option.

    Both S3 and CloudFront allow domain aliases, however CloudFront allows multiple aliases so that d1.mystatics.com, d2.mystatics.com and d3.mystatics.com could all point to the same location increasing the capacity for parallel downloads (this used to be recommended by Google but with the introduction of SPDY and HTTP/2 is of lesser importance).

    CloudFront also supports CORS as of 2014 (thanks sergiopantoja).

    * Note: S3 can now automatically replicate to additional regions as of 2015.

    0 讨论(0)
  • 2020-12-12 09:02

    You can see some Comparison between Amazon S3 and Amazon Cloudfront from here : http://www.bucketexplorer.com/documentation/cloudfront--amazon-s3-vs-amazon-cloudfront.html

    [Disclosure : Bucket Explorer]

    0 讨论(0)
  • 2020-12-12 09:03

    Another major difference is that CloudFront allows you to mirror the site on your server. Cloudfront then caches the files such as images, mp3 or video using its content delivery network.

    This saves you having to duplicate your assets as you would when you use Amazon S3.

    However, after a file expires, CloudFront will fetch it again from your live site (at cost). So cloud front is best for frequently accessed files, and less so for infrequently accessed ones.

    One way to set the file expiry for apache is in .htaccess. For example

    <filesMatch "\\.(mp3|mp4)$">
    Header set Cache-Control "max-age=648000, private"
    </filesMatch>
    
    0 讨论(0)
  • 2020-12-12 09:05

    Amazon S3 is a Simple Storage Service, this can be used large amount of information i.e. Videos, Images, PDF etc.

    CloudFront is a Content Delivery Network, which is closer to the end user and is used to make the information available on Amazon S3 in the least possible time.

    A sample use case is Video on Demand.

    1. You stores your videos at one place. S3 stores all the pre-recorded videos in different formats.
    2. You have global user case
    3. CloudFront is used to cache the video to edge locations. This can be used to deliver content to the end user. Location is picked up automatically based on the closest physical edge location. Currently there are around 51 edge locations.

    Some advantages of using CloudFront for right use case:

    1. Improved Latency - Better end user experience.
    2. Possible reduced data transfer cost. As the data is not every-time transferred from same S3 bucket in a particular AWS region.

    Other possible use cases:

    1. Live streaming
    2. Gaming
    3. Website Acceleration
    0 讨论(0)
  • 2020-12-12 09:06

    One aspect missed here is:

    Amazon Cloudfront also offers lower prices than Amazon S3 at higher usage tiers.

    • Cloudfront CDN is for distribution of content across multiple servers geographically distributed (CSS, JS)

    • Whereas s3 is more of a per user less used resources store (user images, PDFs).

    You can serve your Cloudfront resources from an s3 bucket completely bypassing your web server.

    (Useful in situations where your web server pre-compiles and stores images and java-script. storing them on s3 means your server memory footprint is reduced )

    Ex: On Heroku Slugs (complied application sizes can be reduced by using s3 and wrapping it with cloud-front CDN will improve throughput)

    0 讨论(0)
提交回复
热议问题