Learn About the Content Delivery Network
After completing this unit, you’ll be able to:
- Describe what a content delivery network (CDN) is.
- Identify and explain the benefits of Amazon CloudFront.
What if you were a software developer for a video streaming service and wanted to improve streaming quality for your customers? How would you deliver hours of content while dealing with expected traffic spikes for the more popular videos?
This is where a content delivery network (CDN) comes in. A CDN is a globally distributed system of caching servers. It caches copies of frequently requested content. The CDN delivers a local copy from a cache edge or point of presence (PoP) for fastest delivery.
Recall edge cache and point of presence from AWS Cloud Basics. We dive deeper into these services in this module.
Say Hello to Amazon CloudFront
Amazon CloudFront is a fast CDN service. It securely delivers data, videos, and applications. It makes application programming interfaces (APIs) accessible to customers around the globe, with low-latency (or time delay) and high-transfer speeds, all within a developer-friendly environment.
Amazon CloudFront is ideal for media and entertainment, gaming, social media, and many more use cases.
Amazon CloudFront uses a network of edge locations and regional edge caches to ensure lower latency for end users. These are smaller collections of servers with wider distribution than the Availability Zones.
Amazon CloudFront ensures that end-user requests are served by the closest edge location. As a result, viewer requests and the system’s response travel shorter distances, improving performance for your customers.
As objects become less popular, individual edge locations might remove those objects to make room for more popular content. For the less popular content, CloudFront has regional edge caches. Regional edge caches are CloudFront locations that are deployed globally and are close to your viewers. They are located between your origin server and the global edge locations that serve content directly to viewers. A regional edge cache has a larger cache than an individual edge location, so objects remain in the regional edge cache longer.
Amazon CloudFront only queries Availability Zones, your origin servers, for content that isn’t cached.
Discover How Amazon CloudFront Works
After you configure Amazon CloudFront to deliver your content, here’s what happens when users request your objects.
- A user accesses your website or application and requests one or more objects, such as an image and HTML files.
- DNS routes the request to the CloudFront edge location that can best serve the request—typically the nearest CloudFront edge location in terms of latency.
- In the edge location, Amazon CloudFront checks its cache for the requested files. If the files are in the cache, CloudFront returns them to the user. If the files are not in the cache:
- Amazon CloudFront checks the regional edge location for the requested files and returns them to the user if they are available.
- If the files are neither at the edge location nor the regional cache location, Amazon CloudFront forwards the request for the files to your origin server(s) for the corresponding file type—for example, to your Amazon S3 bucket for image files and to your HTTP server for the HTML files.
- The origin servers send the files back to the CloudFront edge location.
- As soon as the first byte arrives from the origin, Amazon CloudFront begins to forward the files to the user. CloudFront also adds the files to the cache in the edge location and the regional edge cache for the next time someone requests those files.
Control Cache Duration with Amazon CloudFront
You can control how long your files stay in an Amazon CloudFront cache before CloudFront forwards another request to your origin server. Here are some things to consider when you configure the duration in cache.
- Reducing the duration allows you to serve dynamic content.
- Increasing the duration means that your users get better performance because your files are more likely to be served directly from the edge cache. A longer duration also reduces the load on your origin.
- By default, each file automatically expires after 24 hours, but you can change the default behavior by adjusting the time to live (TTL) settings for CloudFront.
Amazon CloudFront works seamlessly with other AWS services, including:
- AWS Shield for distributed denial of service (DDoS) mitigation
- Amazon Simple Storage Service (Amazon S3) or Amazon Elastic Compute Cloud (Amazon EC2) as origins for your applications
- Lambda@Edge to run custom code and customize the user experience
Other features include:
- A global network of edge locations and regional edge caches
- Network optimizations for better performance
- Protection against network and application layer attacks
- Full-featured API operations and DevOps tools
- Flexible pay-as-you-go publicly available pricing and committed-traffic private pricing
The next unit explores the benefits of Amazon EC2 Auto Scaling.