Amazon Web Services – Introduction to CloudFront CDN
Amazon CloudFront is a global web service that allows you to securely deliver content to your users with low latency and high availability. It does so by further delivering content safely. This service helps to built high performance and security in your application. CloudFront works for both static and dynamic content such as .html, .css etc. CloudFront delivers the content worldwide with best possible performance. It also helps in speedy distribution of content.
How is this done?
Cloudfront uses edge locations to serve the user’s request.
- Origin server: It can be an S3 bucket, EC2 instance, or your own HTTP server where files or objects are stored. Furthermore, origins can be ELB (Elastic load balancer) or Route 53.
- Edge location: This is where the contents are cached. The data expires after a certain amount of time. After the data expires, the latest version of data is accessed from the origin server. Amazon regularly adds edge locations.
- Regional Edge cache: Regional edge cache has a larger cache as compared to edge location. It can make data accessible even faster when users are requesting less popular content. Since the data stored at the edge location expires in a definite amount of time ( 24 hours expiration period by default, you can change the expiration period by setting cache-control header), edge locations can fetch data from regional edge cache rather than accessing it from the origin server thus retrieving the data even faster.
- The user requests the data from the nearest edge location.
- If the cached data is present at the edge location then the request is served from the edge location.
- If the data is not present at the edge location then it is fetched from the regional edge cache (regional cache has a larger cache width).
- In the absence of a regional edge cache, the data is fetched directly from the origin server after expiration. But using regional edge cache provides low latency.
To know from which origin server the CloudFront needs to fetch the files, it uses CloudFront distribution.
Following are some of the use cases of Cloudfront:
- When you have users distributed worldwide, using cloudfront is a good practice to reduce latency.
- Cloudfront can help your users access the popular content of your website with low latency or in less amount of time.
- Cloudfront can be used to serve live and on-demand video streaming.
- Acceleration of static content delivery
- Encrypts fields via system processing
Following are the benefits of using cloudfront:
- Cloudfront can be used to deliver both static as well as dynamic content with faster performance.
- Protection against DDOS attacks.
- Protection against layer 3 and 4 network attacks.
- Cloudfront can be integrated with AWS WAF for application-layer protection.
- You can restrict your content access.
- CloudFront is cost effective as it works on pay-as-you-go pricing model.
- Provides an option to encrypt your data with a free custom TLS certificate from ACM (Amazon Certificate manager) or using your own imported certificate.