何时使用 Amazon Cloudfront 或 S3

发布于 2024-09-10 23:00:07 字数 1696 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

君勿笑 2024-09-17 23:00:07

Amazon S3 专为某一特定地理区域内的大容量、低成本文件存储而设计。*存储和带宽成本相当低。

Amazon CloudFront 是一个内容交付网络 (CDN),它在尽可能靠近用户的边缘位置代理和缓存 Web 数据。

当最终用户使用此域名请求对象时,他们会自动路由到最近的边缘站点,以高性能地交付您的内容。 (亚马逊

CloudFront 提供的数据可能来自 S3,也可能不是。由于它对传输速度进行了更优化,因此带宽成本会更高一些。

如果您的用户群是本地化的,那么使用 S3 或 CloudFront 不会有太大差异(但您必须为 S3 存储桶选择正确的位置:美国、欧盟、亚太地区)。如果您的用户群遍布全球,并且速度很重要,CloudFront 可能是更好的选择。

S3 和 CloudFront 都允许域别名,但 CloudFront 允许多个别名,以便 d1.mystatics.comd2.mystatics.comd3.mystatics.com 可以全部指向同一位置,从而增加并行下载的容量(这曾经是 Google,但随着 SPDY 的引入,HTTP/2 的重要性降低了)。

CloudFront 自 2014 年起还支持 CORS(感谢 sergiopantoja)。

* 注意:自 2015 年起,S3 现在可以自动复制到其他区域。

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.

晨与橙与城 2024-09-17 23:00:07

CloudFront 和 S3 存储桶不一样。通俗地说:CloudFront 使您能够通过边缘位置的内容交付网络 (CDN) 加速 Web 内容的内容交付,而 S3 存储桶是您存储实际文件的位置。 CloudFront 源不一定来自 S3,但为了更轻松地可视化 S3 与 CloudFront 的集成:
输入图像描述这里

CloudFront and S3 Bucket is not the same. In layman's terms: CloudFront enables you to accelerate content delivery of your web contents via Content Delivery Network (CDN) in edge locations, whereas S3 Buckets are where you store your actual files. CloudFront sources may not necessarily be from S3 but for easier visualization of S3 integration with CloudFront:
enter image description here

浅语花开 2024-09-17 23:00:07

Amazon CLOUDFRONT 和 S3 是 Amazon Web Services 提供的两种不同的服务。

Amazon S3 是一种存储服务,我们可以在其中存储静态文件,例如:

css、图像、javascript、视频等...

Amazon CloudFront 是一个中间件,它代表在用户从 AWS 和特定区域的 S3 数据中心请求文件之间,CloudFront 用于加快将静态和动态 Web 内容从 S3 分发到用户的速度。

您可以通过一个示例更好地理解它:-

例如,您的 S3 位于美国东部(弗吉尼亚北部)的 AWS 区域,该数据中心位置用于存储您的文件。

如果来自印度的用户尝试从弗吉尼亚州的 AWS 服务器访问文件,那么用户将需要通过请求前往该特定位置,这将花费大量时间。

CloudFront 的作用是充当用户和 AWS S3 之间的中间件。


最常用的文件可以缓存在 CloudFront 上,它的作用是将这些文件复制到边缘站点(为了以较低的延迟向最终用户交付内容,Amazon CloudFront 使用全球边缘站点网络进行内容交付)。

如果内容已位于延迟最低的边缘位置,CloudFront 会立即传送该内容。如果内容当前不在该边缘位置,CloudFront 会从 Amazon S3 存储桶中检索该内容并尽快将其提供给用户。

每个请求都会获得从 CloudFront 到 S3 的新 DNS,因此这将导致流量降低以及更多的并行请求处理。

以下是截至 2016 年 7 月的当前边缘站点列表:-

美国

  • 弗吉尼亚州阿什本 (3)
  • 佐治亚州亚特兰大 伊利诺伊州
  • 芝加哥 德克萨斯州
  • 达拉斯/沃斯堡 ( 2)
  • 加利福尼亚州海沃德 佛罗里达州
  • 杰克逊维尔
  • 加利福尼亚州洛杉矶 (2)
  • 佛罗里达州迈阿密
  • 纽约州纽约 (3)
  • 新泽西州纽瓦克 加利福尼亚州
  • 帕洛阿尔托 加利福尼亚州
  • 圣何塞 华盛顿州
  • 西雅图 华盛顿州
  • 南本德
  • 密苏里州圣路易斯

欧洲

  • 荷兰阿姆斯特丹 (2)

  • 爱尔兰都柏林

  • 德国法兰克福 (3)

  • 英国伦敦 (3)

  • 西班牙马德里

  • 马德里

    法国马赛

  • 意大利米兰

  • 法国巴黎 (2)

  • 瑞典斯德哥尔摩

  • 波兰华沙

亚洲

  • 印度金奈

  • 香港 (2)

  • 印度孟买

  • 孟买

    菲律宾马尼拉

  • 印度新德里

  • 日本大阪

    >

  • 韩国首尔 (3)

  • 新加坡 (2)

  • 台湾台北

  • 日本东京 (2)

澳大利亚

  • 澳大利亚墨尔本

  • 澳大利亚悉尼

南美洲

  • 巴西圣保罗

  • 巴西里约热内卢

由此您可以得出结论如果受限制的用户来自与您的 S3 托管所在的同一区域,那么您不需要使用 CloudFront,如果全球范围内的用户数量增加,那么您绝对应该使用 CloudFront 来获得更好的延迟和流量控制。

Amazon CLOUDFRONT and S3 are two different services provided by Amazon Web Services.

Amazon S3 is a storage service in which we can store static files like:

css, images, javascripts,videos, etc...

Amazon CloudFront is a middle-ware which stands in between a user requesting for a file from AWS and the S3 data center in a specific region, CloudFront is used to speeds up distribution of your static and dynamic web content from S3 to the User.

You can understand it better by an example:-

For example, your S3 is located in AWS region US East (N. Virginia) which a data center location to store your files.

If a user from India tries to access a file from a AWS server in Virginia, then user would need to go to that specific location with a request, and this will take a lot of time.

What CloudFront does is that it stands as a middleware between user and AWS S3.


The most often used files can be cached on CloudFront and what it does is, it replicates those files on edge locations (To deliver content to end users with lower latency, Amazon CloudFront uses a global network of edge locations for content delivery).

If the content is already in the edge location with the lowest latency, CloudFront delivers it immediately. If the content is not currently in that edge location, CloudFront retrieves it from an Amazon S3 bucket and provides it to user as faster as it can.

Every request is given a new DNS from CloudFront to the S3, so this would result in lower traffic as well as more parallel request processing.

Following is the list of current edge locations as per July-2016:-

United States

  • Ashburn, VA (3)
  • Atlanta, GA
  • Chicago, IL
  • Dallas/Fort Worth, TX (2)
  • Hayward, CA
  • Jacksonville, FL
  • Los Angeles, CA (2)
  • Miami, FL
  • New York, NY (3)
  • Newark, NJ
  • Palo Alto, CA
  • San Jose, CA
  • Seattle, WA
  • South Bend, IN
  • St. Louis, MO

Europe

  • Amsterdam, Netherlands (2)

  • Dublin, Ireland

  • Frankfurt, Germany (3)

  • London, England (3)

  • Madrid, Spain

  • Marseille, France

  • Milan, Italy

  • Paris, France (2)

  • Stockholm, Sweden

  • Warsaw, Poland

Asia

  • Chennai, India

  • Hong Kong (2)

  • Mumbai, India

  • Manila, the Philippines

  • New Delhi, India

  • Osaka, Japan

  • Seoul, Korea (3)

  • Singapore (2)

  • Taipei, Taiwan

  • Tokyo, Japan (2)

Australia

  • Melbourne, Australia

  • Sydney, Australia

South America

  • São Paulo, Brazil

  • Rio de Janeiro, Brazil

From this you can conclude that if the users are limited are from the same region as your S3 is hosted on, then you do not require to go for CloudFront, and if the number of users is increased on global level then you should definitely use CloudFront for better latency and traffic control.

各自安好 2024-09-17 23:00:07

另一个主要区别是 CloudFront 允许您在服务器上镜像站点。然后,Cloudfront 使用其内容交付网络缓存图像、mp3 或视频等文件。

这使您不必像使用 Amazon S3 时那样复制资产。

但是,文件过期后,CloudFront 将从您的实时站点再次获取该文件(按成本)。因此,云前端最适合经常访问的文件,而对于不经常访问的文件则不太适用。

为 apache 设置文件过期时间的一种方法是在 .htaccess 中。例如

<filesMatch "\\.(mp3|mp4)$">
Header set Cache-Control "max-age=648000, private"
</filesMatch>

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>
夜唯美灬不弃 2024-09-17 23:00:07

通过 S3 使用 CloudFront 的另一种情况是,您可以在 CloudFront 中使用自定义域的 SSL 证书,而在 S3 中则不能。恕我直言,这是一个很好的理由!

Another case for using CloudFront over S3 is that you can use an SSL certificate to a custom domain in CloudFront whereas you cannot in S3. A pretty good reason imho!

记忆里有你的影子 2024-09-17 23:00:07

Amazon S3 是一种简单存储服务,可用于存储大量信息,即视频、图像、PDF 等。CloudFront

是一种内容分发网络,更接近最终用户,用于使信息在 Amazon S3 上可用尽可能少的时间。

一个示例用例是视频点播。

  1. 您将视频存储在一个地方。 S3以不同的格式存储所有预先录制的视频。
  2. 您有一个全局用户案例,
  3. CloudFront 用于将视频缓存到边缘位置。这可用于向最终用户传送内容。根据最近的物理边缘位置自动拾取位置。目前大约有 51 个边缘站点。

在正确的用例中使用 CloudFront 的一些优势:

  1. 改善延迟 - 更好的最终用户体验。
  2. 可能降低数据传输成本。由于数据并非每次都从特定 AWS 区域的同一个 S3 存储桶传输。

其他可能的用例:

  1. 直播
  2. 游戏
  3. 网站加速

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
筱武穆 2024-09-17 23:00:07

这里遗漏的一个方面是:

在更高的使用级别上,Amazon Cloudfront 还提供比 Amazon S3 更低的价格。

  • Cloudfront CDN 用于跨地理分布的多个服务器分发内容
    (CSS, JS)

  • 而 s3 更像是每个用户较少使用的资源存储(用户图像、PDF)。

您可以完全绕过 Web 服务器从 s3 存储桶提供 Cloudfront 资源。

在 Web 服务器预编译并存储图像和 java 脚本的情况下很有用。将它们存储在 s3 上意味着减少服务器内存占用

例如:在 Heroku Slugs 上(可以减少编译的应用程序大小 )通过使用 s3 并将其与云前端 CDN 封装将提高吞吐量)

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)

伴梦长久 2024-09-17 23:00:07

首先我想解释一下,Amazon S3 是云存储,Cloud Front 是内容分发网络 (CDN)。

因此,您可以将文件存储在 S3 上,并创建分发以通过 Internet 提供内容。您还可以为特定区域创建分发。

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.

一身软味 2024-09-17 23:00:07

如果您正在寻找一个全球分布式存储系统来防止区域/区域出现故障,Amazon S3 是一个很棒的对象存储平台。它也非常适合非事务性和变化的静态/固定内容,例如图片、视频、图像、备份等。希望有帮助!

Amazon S3 is a great object storage platform if you are looking for a globally distributed storage system to protect against regions/zones going down. It is also great for static/fixed content that is not transactional and changing such as pictures, videos, images, backups, etc. Hope that helps!

真心难拥有 2024-09-17 23:00:07

这两种服务没有相同的目的,比较它们没有意义。

  • 当您需要存储文件、静态网站、媒体、大文件、日志等时,请使用 S3。
  • 当您需要交付内容时,请使用 Cloudfront
    通过在边缘缓存来实现低延迟和高速度
    全球地点。您可以将 Cloudfront 发行版放在
    静态或动态网站、媒体内容和 API 的前端。

Cloudfront 和 S3 可以组合起来为静态网站或单页应用程序 (SPA) 提供服务。

The two services do not have the same purpose, it makes no sense to compare them.

  • Use S3 when you need to store files, a static website, media, big files, logs, etc.
  • Use Cloudfront when you need to deliver content
    with low latency and high speed by caching it at edge
    locations globally. You can put a Cloudfront distribution in the
    front of a static ou dynamic website, media content and APIs.

Cloudfront and S3 can be combined to serve a static website or an Single Page Application (SPA) .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文