Professional Documents
Culture Documents
Why is this worth doing? Imagine, for example, that your data origin is located in
Brazil and one of your customers in Japan would like to access this data. Without
CloudFront (or a similar solution) this customer would need to send a request to the
other side of the world, transferring the files from a very distant location. This would
result in a request that’s slow to arrive to the destination as well as a slow file
download. Having your customers wait longer to get data often makes for a poor
customer experience.
With CloudFront, however, the files are periodically fetched by CloudFront system
from the location in Brazil and placed onto a set of servers around the world,
including one in Japan. When a user in Japan goes to download the files, the
request will now be served by a nearby server
Amazon EC2. CloudFront supports using an Amazon EC2 server or an Elastic Load
Balancing endpoint as an origin for files in a CloudFront distribution. CloudFront’s
support for custom HTTP/HTTPS origins is what enables this integration, meaning
that it’s also possible to use a non-EC2 server as a file origin.
High cost at scale CloudFront pricing is pay-per-use. This means you pay very little
if the traffic to your Serverless site or application is low. However, as the traffic
grows, the cost of using CloudFront can increase very rapidly.
You can avoid surprises with CloudFront bills by establishing a process to regularly
review your CloudFront usage and give your accounting teams a heads up if any
significant increases in CloudFront traffic (and thus cost) are expected as you
develop your application.
We also recommend only using CloudFront for files where delivery time and speed is
truly important, for example, the assets for your main website’s marketing pages. It’s
likely that most of the files you distribute to your users can be shared directly from S3
or another file storage solution without much impact to the customer experience.
Customer invoices, user-generated video content, and short-lived assets probably
don’t need to be part of your CloudFront distributions.
CloudFront Locations
CloudFront currently offers around 200 edge locations—which consist of content
caches and supporting infrastructure—on five continents. You’ll find the highest
density of edge locations in the United States, Western Europe, and East Asia.
In addition, CloudFront offers 11 regional edge caches in AWS regions around the
world, which act as caches for the caches; instead of having all 200 edge locations
get the original files from your servers, the regional edge caches retain the most
frequently accessed files and serve them to the edge location when it requests the
updated version of a file.
A full list of CloudFront locations, including edge locations and edge caches, is
available on the CloudFront website’s features page.
But using S3 will also likely be slower for your end users, unless they all happen to
be located near the region where your S3 bucket is hosted.
In short, using S3 directly (without CloudFront) can be a good option for cases where
a small amount of extra latency is acceptable for your users.
Google Cloud CDN Google Cloud CDN offers very similar functionality to that of
CloudFront. The key difference is the pricing structure: Google Cloud CDN exposes
more detail about the cache structure and charges for cache lookups, cache fill data
transfer, and cache egress data transfer. The total cost of using Google Cloud CDN
should be in the same range as CloudFront, as most of the cost still lies in the data
transfer charges, and data transfer is priced similarly for both services. The extra
visibility you get into the details of how Google Cloud CDN works through their
pricing model can allow you to reduce the CDN’s cost and optimize its performance.
CloudFlare CDN CloudFlare is a company that provides CDN and related solutions.
The technical implementation of their CDN solution is different from that of
CloudFront and Google Cloud CDN: CloudFlare is built as a reverse proxy.
CloudFlare’s customers point the name servers for their domain(s) to CloudFlare,
whose CDN service then becomes the primary endpoint for all HTTP or HTTPS
requests each domain receives. CloudFlare retrieves any files it’s missing from the
customer’s backend server.
For all cases where latency and download speed are less crucial, we recommend
using S3 directly to reduce the total operating cost of your system.