CloudFront CDN (Computer Delivery Network) is a system of distributed servers that deliver web pages and other web content to a user based on the geographic locations of the user, the origin of the webpage and a content delivery server.
Suppose I am running the website outside the UK and I am serving the website all around the world. When the user wants to access my website, then they request to the web server, and users from different countries will have different latency. For example, People who live in Australia will have more latency than those who stay in India. South Africa has a terrible latency, but they would run internet backbone that makes quicker to connect to the UK. This is how it works with CloudFront CDN in which people spread all around the world, and they can turn on access to the web page, audio files, etc. in the UK.
Key Terminology of CloudFront CDN
- Edge Location: Edge location is the location where the content will be cached. It is a separate to an AWS Region or AWS availability zone.
- Origin: It defines the origin of all the files that CDN will distribute. Origin can be either an S3 bucket, an EC2 instance or an Elastic Load Balancer.
- Distribution: It is the name given to the CDN which consists of a collection of edge locations. When we create a new CDN in a network with aws means that we are creating a Distribution.
The distribution can be of two types:
- Web Distribution: It is typically used for websites.
- RTMP: It is used for Media Streaming.
How CloudFront CDN works
- Edge locations spread all around the world and currently, there are 50 edge locations.
- When the first user requests to get the content, and the request goes to the nearest edge location. The nearest edge will be read first to determine whether it contains the cached data or not. If an edge does not contain the cached data, the edge location pulls the data from the S3 bucket. Suppose the S3 bucket is in Ireland. But this process is not quicker for the first user. However, when the second user accesses the same file, this file is already cached to the edge location, so it pulls the data from its edge location. It speeds up the delivery of the data.
Key points related to the CloudFront CDN
- Amazon CloudFront CDN is used to deliver your entire website, including dynamic, static, streaming, and interactive content using a global network of edge locations.
- When a user requests for content, the request is automatically routed to the nearest edge location so that the content is delivered with the best possible performance.
- Amazon CloudFront CDN is optimized to work with other Amazon web services such as Amazon Simple Storage services (S3), Amazon Elastic Compute Cloud (EC2), Amazon Elastic Load balancing and Amazon Route 53. Amazon CloudFront CDN also works with the non-AWS origin server which stores original and versions of the files.