What is CDN ?
CDN is Content Delivery Network. It is a system of distributed services, that delivers webpages and other web content to a user base based on the geographic locations of the users, the origin of the web page and and a content delivery server.
How the users would access without CDN :
Edge Location:
This is the location where the content is cached. This is separate to an AWS Region/AZ.
We can look at the different locations by going to the
Origin :
This is the origin of all the files that CDN will distribute. This can be an S3 bucket, an EC2 Instance, an Elastic Load Bucket or Route53.
Distribution :
This is a name given to the CDN which consists of a collection of Edge Locations.
CDN :
When the first user makes a request, the request goes to the edge location.
Edge location checks if the file is cached in that location or not.
If it doesnt, it pulls from S3, and caches it.
From the second user, the file is already cached at that location and can be much faster from the second user in that region.
Amazon CloudFront can be used to deliver your entire website, including dynmic, static, streaming and interactive content using a global network of edge locations. Requests for the content are automatically routed to the nearest edge location, so the content is delivered with the best possible performance.
CloudFront is optimized to work with other amazon service like the S3, EC2, Load balancing, Route53.
CloudFront also works with any non AWS origin server, which stores the original, definitive versions of your files.
Two Types of Distributions;
Web distributions: Typically used for websites.
RTMP : used of media streaming(adobe flash)
Edge locations are not for read only.
We can set a TTL for the object to be cached at the edge location.
You will be charged to clear the cached object.