‫Now let's talk about CloudFront.
‫CloudFront is a content delivery network, or CDN,
‫so anytime you see CDN at the exam, think CloudFront.
‫It improves the read performance
‫by caching the content of your website
‫at the different edge locations.
‫And because your content is cached all around the world,
‫then your users all around the world
‫will have a lower latency,
‫and this will improve the user experience.
‫CloudFront is made of 216 points of presence globally,
‫which correspond to the AWS edge locations around the world.
‫And AWS keeps on adding locations
‫to improve user experience even further everywhere.
‫On top of it, by having the content distributed globally
‫we are getting DDoS protection.
‫So DDoS is a sort of attack
‫where all your servers around the world
‫are getting attacked at the same time,
‫we'll see this later on in this course,
‫and the idea is that CloudFront
‫because your application is worldwide,
‫then you're protected against these attacks,
‫also using something called Shield
‫and Web Application Firewall,
‫that we will be seeing in the security section.
‫So if we wanted to look at a map of the world,
‫these are the map and we see some edge locations
‫as well at edge caches.
‫And so say we had created an S3 bucket and a website
‫on our S3 bucket in Australia,
‫but we had a user maybe in America,
‫then what the user will do
‫is that it will request the content
‫from an American edge location using CloudFront,
‫and CloudFront will be able
‫to fetch the content from Australia.
‫Now, if another user in the US
‫will be requesting the same content,
‫then it will be served directly from the edge
‫and it will not go all the way
‫to Australia to serve that content.
‫Same if a user is in China,
‫then it will be talking to a Chinese point of presence
‫and then redirected to the S3 bucket,
‫and then the content will be cached at the edge.
‫CloudFront has several type of origins.
‫For example, you have S3 bucket,
‫which is used to distribute files
‫and cache them at the edge using CloudFront.
‫And to guarantee that only CloudFront
‫can access your S3 bucket,
‫you can use something called the Origin Access Control, OAC,
‫which is replacing the older Origin Access identity, OAI.
‫CloudFront can also be used as a way
‫to send data into an S3 bucket.
‫So to upload data to file to S3,
‫which is called an ingress.
‫You can have CloudFront as well instead
‫in front of any custom origin HTTP backend.
‫So that could be an Application Load Balancer,
‫that could be an EC2 instance,
‫and the S3 website,
‫but first you must enable the bucket as a static S3 website,
‫or really any HTTP backend you want.
‫So at a high level, how does CloudFront work?
‫We have the edge location all around the world, okay?
‫And then it will be connecting to your origin.
‫So would it be an S3 bucket or an HTTP server?
‫And when the client connects
‫and does an HTTP request into your edge location,
‫then the edge location will see
‫if it has it in the cache.
‫If it doesn't have it in the cache,
‫then it will go to the origin to get the request results.
‫And then once you retrieve the results,
‫it will be caching it into a local cache
‫so that if another client requests the same content
‫from the same edge location,
‫then the edge location does not
‫need to go to the origin.
‫So if we have S3 as an origin,
‫then if we look at the cloud,
‫your S3 bucket is your origin in some region,
‫and then you have edge locations all around the world,
‫for example, at Los Angeles.
‫And your users accessing the edge location in Los Angeles
‫will get their content directly served
‫through the edge location,
‫but first the edge location
‫will get it from the origin S3 bucket
‫through the private network.
‫And the S3 bucket will be secured
‫using an Origin Access Control
‫and by modifying the S3 bucket policy on the S3 bucket.
‫So this is the same when we have a user
‫in Sao Paulo, for example, in Brazil.
‫Again, this will be another edge location
‫which will be serving users close to Brazil,
‫and then it will be a private connection
‫between your edge location
‫and your S3 bucket, and so on.
‫So using CloudFront and the edge locations,
‫we can see that the content of our S3 bucket in one region
‫can be distributed all around the world
‫through the edge locations or points of presence.
‫So one question that's common
‫is what is the difference between CloudFront
‫and something like S3 Replication?
‫Well, if you have CloudFront,
‫you're using the Global Edge network,
‫so this is about 216 points of presence,
‫and the files are going to be cached
‫in each edge location, maybe for a day.
‫So this is amazing if you have static content
‫that must be able to be available
‫everywhere around the world.
‫S3 Cross-Region Replication is different,
‫it must be set up for each region
‫you want replication to happen,
‫so this is not for every region in the world.
‫And then files are going to be updated in near real-time,
‫so there's no caching that happens.
‫And it is only for read only,
‫and so this is great if you have dynamic content
‫that needs to change all the time
‫and be available at low-latency in a few regions.
‫So they serve very different purposes,
‫CloudFront is a CDN,
‫which is to cache content all around the world,
‫whereas S3 Cross-Region Replication
‫is to really replicate an entire bucket into another region.
‫So hopefully that makes sense about CloudFront.
‫In the next lecture, we'll have a play
‫and see how we can set up a CloudFront distribution
‫on the cloud for an S3 bucket.
‫So I will see you in the next lecture.