Amazon CloudFront Study Notes--01

CloudFront Configuration Steps

  • 1. Configure your origin servers from which CloudFront will fetch your files for distribution from CloudFront locations around the world.

    • The origin server will store the original final version of your object.
    • If you serve content over HTTP, your origin server will be an Amazon S3 bucket or an HTTP server, for example, a web server.
    • Your HTTP servers can run on Amazon Elastic Compute Cloud (Amazon EC2) instances or servers that you manage; these servers are also known as "custom origins."

    • If you use the Adobe Media Server RTMP protocol to distribute media files on demand, your origin server is always an Amazon S3 bucket.

  • 2. You upload your file to your origin server.
    • Your files, also called objects, typically include web pages, images, and media files, but can be anything that can be served over HTTP or a supported version of Adobe RTMP (the protocol used by Adobe Flash Media Server).
    • If you're using an Amazon S3 bucket as your origin server, you can make the objects in the bucket publicly readable so that anyone who knows their CloudFront URLs can access them. You can also choose to make objects private and control who can access them.
  • 3. Create a CloudFront distribution that tells CloudFront which origin servers to get your files from when users request files through your website or application.
    • You also need to specify some details, such as whether you want CloudFront to log all requests and whether you want this distribution to be enabled as soon as it is created.
  • 4. CloudFront assigns the new distribution a domain name and displays it in the CloudFront console, or returns it in response to programmatic requests (such as API requests).
  • 5. CloudFront sends your distribution's configuration (not your content) to all of its edge locations, which are collections of servers located in geographically dispersed data centers where CloudFront caches copies of your objects.
    write picture description here

User access steps

  • 1. A user visits your website or application and requests one or more objects, such as image files and HTML files.
  • 2. DNS routes the request to the CloudFront node that can best serve the user's request, usually the closest CloudFront node as measured by latency.
  • 3. At the edge location, CloudFront checks its cache for the existence of the requested file. If these files are in the cache, CloudFront sends them back to the user. If these files are not in the cache, it does the following:
    • a. CloudFront will compare the request to the instructions in the distribution, and then forward the file request to the applicable origin server based on the corresponding file type, for example, to an Amazon S3 bucket for image files, or to an HTTP server for HTML files .
    • b. The origin server sends these files back to the CloudFront node.
    • c. The origin server sends these files back to the CloudFront node.
    • d. CloudFront starts forwarding the file to the user as soon as the first byte in the origin arrives. CloudFront also adds the files to the cache on the edge location for the next time someone requests them.
      write picture description here

How zone caching works

  • 1. Regional Edge Caches are CloudFront locations deployed globally, in close proximity to viewers. These locations sit between origin servers and global edge locations, serving traffic directly to viewers. When your objects become less popular, individual edge sites may move them out to make room for more popular content. Regional edge caches have a larger cache width than any single edge site, so your objects will remain in the cache at the nearest regional edge cache location longer. This helps bring more of your content closer to the viewer and reduces the need for CloudFront to return to the origin server, while improving overall viewer performance.

  • 2. When a viewer makes a request through your website or application, DNS routes the request to the CloudFront edge location that best serves the user's request. This location is usually the closest CloudFront edge location in terms of latency. In edge locations, CloudFront checks its cache for the existence of the requested file. If these files are in the cache, CloudFront sends them back to the user. If the file is not in the cache, the edge server will go to the nearest regional edge cache to fetch the object. In a regional edge cache location, CloudFront will again check its cache for the requested file. If the file is in the cache, CloudFront forwards the file to the requested edge location. CloudFront starts forwarding files to users as soon as the first byte of the regional edge cache location arrives. CloudFront also adds the files to the cache on the requested edge location for the next time someone requests them.

  • 3. For files not cached at edge locations and regional edge cache locations, CloudFront compares the request to the instructions in the distribution and forwards the file request to the applicable origin server. Once the origin server sends the files back to the regional edge cache location, the files are forwarded to the requested edge location, and CloudFront forwards the files to the user. In this case, CloudFront also adds the files to the cache in the regional edge cache location as well as to the edge location for the viewer to request the files the next time. All edge locations in a region now share a local cache, eliminating multiple requests to origin servers. Additionally, CloudFront maintains a persistent connection to the origin server so that files can be pulled from the origin server as quickly as possible.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325999532&siteId=291194637