Before going to Cloudfront functionality, we need to understand the CDN (Content delivery network) first, as Cloudfront is nothing but just a FAAS (functions as a service) platform provided by AWS, which we generally relate to the content delivery network(Cloudfront) in AWS cloud service provider.
CDN(Content Delivery Network)
A CDN is kind of a geographically distributed group of servers that are attached so that they can communicate with each other and provide fast delivery of any content such as HTML pages, images, videos, etc. The popularity of CDN services is continuously growing among organizations such as Netflix, Facebook, and Amazon as their major web traffic is served through CDN.
Now, let’s take a deep understanding of how CDN works in the AWS Cloudfront service.
We could think of a CDN as an ATM. Having a cash machine on practically every corner makes it fast, immediate access, and efficient to get money. There’s no wait time in long bank lines to get our money in hand.
In today’s time, a large portion of all internet content is delivered through CDNs. Here is a simple example:
If we were in New York and wanted to view the website of our favorite store in London that’s hosted on a server in the UK, we would have experienced slow content load times because the request had to travel all the way across the Atlantic Ocean. To resolve this, a CDN would store a cached version of the London website content in multiple geographical locations around the world, also called “points of presence” (PoPs). These PoPs contain their own caching servers and are responsible for delivering that content close to where we’re located in New York.
Content delivered from a server closest to your physical location gives you a faster, high-performance web experience.
What is Cloudfront?
Amazon Cloudfront is a web service that gives business and web application developers an easy and cost-effective way to distribute content with low latency and high data transfer speed.
What does latency mean?
What does latency mean let’s understand with this given picture?
For User1 the total travel period is 4s and in the other scenario, for User2 the travel time is 2s so generally what we choose, we always go for the low latency(2s) time. In our day-to-day routines, we use the services on the internet like Wikipedia, youtube, or websites where we can search for images, videos, etc. backed up by CDN.
To deliver content to end users with lower latency, Amazon CloudFront uses a global network of 310+ Points of Presence (300+ Edge locations and 13 regional mid-tier caches) in 90+ cities across 47 countries
Technically Amazon CloudFront works in the following manner :
a) A user accesses the application or website and requests one or more objects such as an image or an HTML file.
b) DNS then routes the request to CloudFront’s Edge location which is nearest to the location from where the request is made. Nearest distance is measured in terms of latency as we already discussed what latency means.
c) In the edge location, CloudFront checks its cache for the requested files. If the files are available in the cache, CloudFront returns them to the user. If the files are not available in the cache, it does the following:
- CloudFront compares the request with the specifications in your distribution and forwards the request for the files to the applicable origin server for the corresponding file type—for example, to the 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.
- CloudFront also adds the files to the cache in the edge location for the next time someone requests those files.
- As soon as the first byte arrives from the origin, CloudFront begins to forward the files to the user.
Major components of AWS Cloudfront :
Distributions:-CloudFront distribution to tell CloudFront where you want the content to be delivered from, and the details about how to track and manage content delivery
Origins:- An origin is the location where content is stored, and from which CloudFront gets content to serve to viewers, at least one origin should be created. We can use several different kinds of origins with CloudFront. For example, we can use an Amazon S3 bucket, a MediaStore container, an Application Load Balancer, or an AWS Lambda function URL.
WAF(Web Application Firewall):- AWS WAF is a web application firewall that lets you monitor the HTTP and HTTPS requests that are forwarded to CloudFront, and lets you control access to your content.
Benefits of CloudFront
- CloudFront runs on the AWS global network backbone that allows for efficient transmission of requests between the CloudFront Edge locations and other AWS services, across regions and applications.
- Cache retention in CloudFront has emerged as a key contributor to performance.
- AWS edge provides a scalable, reliable, and high-performance security perimeter for your applications and content.
- Amazon CloudFront, content, APIs, or applications can be delivered over HTTPS using the latest version of Transport Layer Security (TLSv1.3) to encrypt and secure communication between viewer clients and CloudFront.
- It supports multiple origins for backend architecture redundancy.
AWS CloudFront is a globally distributed network offered by AWS which securely delivers content to the end-users with a high transfer speed and low latency. We saw how AWS CloudFront delivers the content. It has various benefits and uses like serving on-demand live streaming videos, encrypting specific fields throughout system processing, and accelerating static website content delivery. But we won’t end here, shortly we would be covering the real-time implementation of Cloudfront and more features in our coming blog series.
Opstree is an End to End DevOps solution provider