Teamitek

AWS 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.

  1. CloudFront is a global service
  2. Amazon CloudFront is a web service that speeds up distribution of your static and dynamic web content, such as html, .CSS, .JS, and image files to your users.
  3. CloudFront delivers your content through a worldwide network of data centers called edge locations.
  4. When a user requests content that you are serving with CloudFront, the user is routed (via DNS resolution) to an edge location that provides the lowest latency, so that content is delivered with the best possible performance.
  5. If the content is already in the edge location with the lowest latency, CloudFront delivers it immediately.
  6. This dramatically reduces the number of networks that your users request must pass through which improves performance.   
  7. CloudFront also keeps persistent connection with the origin servers so files are fetched from the origins as quickly as possible.

Different ways to access Amazon CloudFront:

  • AWS management console.
  • AWS SDKs.
  • CloudFront API.
  • AWS command line interface.

CloudFront edge locations:

  • Edge locations are not tied to availability zone or regions.
  • Amazon CloudFront has 216 points of presence (205 edge locations and 11 regional edge caches) in 84 cities across 42 countries.

CloudFront Regional edge cache:

Amazon CloudFront has added several regional edge cache locations globally at close proximity to your viewers.

  • They are located between your origin web server and the global edge locations that serve content directly to your viewers.
  • As objects become less popular, individual edge locations may remove those objects to make room for more popular content.
  • Regional edge cache working as an alternative of origin to reduce the burden of origin.
  • Regional edge caches have a larger cache width than any individual edge location, so objects remain in the cache longer at the nearest regional edge caches.

Regional edge cache working:

  • When a viewer makes a request on your website or through your application, DNS routes the request to the CloudFront edge location that can best serve the user’s request.
  • This location is typically the nearest CloudFront edge location in terms of latency
  • In the edge location, CloudFront checks its cache for the requested files.
  • If the files are in the cache, CloudFront returns them to the user.
  • If the files are not in the cache, the edge servers go to the nearest regional edge cache to fetch the object.
  • Regional edge cache have feature parity with edge location for e.g. cache invalidation request removes an object from both edge caches and regional edge cache before it expires.
  • The next time the viewer requests the object, CloudFront returns to the origin to fetch the latest version of the object.
  • Proxy method PUT/POST/OPTIONS/DELETE go directly to the origin from the edge locations and do not proxy through the regional edge caches.
  • Dynamic content as determined at request time, does not flow through regional edge cache, but goes directly to the origin.

How to setup CloudFront?

  1. Sign in to AWS management console
  2. Then first select the s3 service from the services tab.

Selection of S3 service

3. Then click on create bucket and create a bucket with a unique name.

create-bucket-with-a-unique-name-3

4. Then make the bucket publicly accessible.

bucket Publicly Accessible

5. After that use default setting and click on create bucket.

Create-bucket-

6. Now after bucket creation just upload one image and give public read permission to that image.

7. Now in AWS services go to CloudFront and create distribution.

8. Now in create distribution choose the Amazon s3 bucket created in the origin domain name and leave the remaining fields as default.

9. Now in default cache behavior setting select allow https methods according to your need for this time I am taking (GET, HEAD, POST, OPTIONS, DELETE) option.

10. And now set TTL for cache we can set max TTL for one year and by default TTL is of 24hrs.

11. After filling all the details click create distribution.

12. Creation of distribution will take some minutes once creation is completed in status you can see deployed.

13. Now select distribution and then click the distribution setting where we can manage all the settings of the created distribution.

14. Now just copy domain name from distribution page and add name in the URL (d2f891ks91jkt3.cloudfront.net/download 123.png) to access the data which 15. we stored in our bucket.

Now enter the copied domain in your browser to access your uploaded data through CDN.

If you need help in configuring this cluster, feel free to email us victor@teamitek.com or call us at +1 810 214 2572.