close

For suitable CDN application scenarios, you can refer to this link (link). This article will use 'website' (Web) as the basis to implement CDN, while also practicing the integration of edge and cloud applications.

Preparation before implementation:

  • Prepare an On-Premises Server in Taiwan as the Origin Host, note down the server's IP address; simultaneously deploy an AWS instance in the Americas region, and test the perceptible speed difference between the domain name used for CDN acceleration and the direct IP connection.

 

Prepare a test HTML website:
Guide to understanding the best practices of CDN application scenarios
  1. Prepare a domain name. For this implementation, we will use the domain "higher-cloud.com" with the website pages hosted at www.higher-cloud.com.
  2. Prepare AWS CloudFront - AWS's CDN service, for website acceleration.
  3. Lastly, prepare an SSL certificate for AWS CloudFront. You can use a free SSL certificate provided by a third-party or one provided by AWS.

 

Implementation Steps:

  1. Sign in to the AWS Management Console and select CloudFront.

Guide to understanding the best practices of CDN application scenarios

 
  1. Choose "Create Distributions"

Guide to understanding the best practices of CDN application scenarios

 
  1. Origin domain wrote www.higher-cloud.com

Guide to understanding the best practices of CDN application scenarios

 
  1. Decide whether to use HTTP or HTTPS for the origin. Alternatively, select "Match Viewer," which determines whether to use port 80 or 443 for caching based on the port accessed by the user. It is recommended to use HTTP (Port 80) for the origin to save the encryption and decryption process, further enhancing the origin fetching speed.

Guide to understanding the best practices of CDN application scenarios

 

  1. Default cache behavier:

Here you are configuring the connection settings for viewers (website users), which can be adjusted according to your needs:

  1. Allow both HTTP and HTTPS access.
  2. Redirect HTTP to HTTPS.
  3. Allow only HTTPS connections.

Leave the rest at default settings.

Guide to understanding the best practices of CDN application scenarios 
 

  1. Cache key and origin requests:
For customizing the origin response and cache policies, you can tailor them according to your business requirements. However, it's recommended to use the default settings unless you have specific customization needs.

Guide to understanding the best practices of CDN application scenarios 

 

  1. Function associations:

If you don't have any specific customizations for how CloudFront handles HTTP requests, keeping the default settings is sufficient.

Guide to understanding the best practices of CDN application scenarios 

 
  1. Setting:

For the Price Class, you can choose based on the regions you want to accelerate distribution to. However, the first option (Use all edge locations) is generally recommended.

  1. AWS WAF Web ACL:

If you have custom ACLs (Access Control Lists) that need to be deployed, you can choose this option, but you'll need to define the rules beforehand.

  1. Alternate Domain Name:

After deploying the CDN, you need to specify the distribution domain name (the domain users will see). It's advisable to define a custom domain name to enhance the visibility of your website and brand. If left blank, AWS will provide a default domain name.

  1. Custom SSL certificate:

You can either provide your own SSL certificate or apply for a free SSL certificate through AWS. If left blank, the alternate domain name you've customized above won't be usable.

  1. After completing the above steps, click on "Create Distribution" to finish the deployment.

Guide to understanding the best practices of CDN application scenarios 

  1. Next, you can try connecting using AWS's default domain and your custom domain.

Guide to understanding the best practices of CDN application scenarios

 
  1.  AWS default domain: dtytosfxel4su.cloudfront.net

Guide to understanding the best practices of CDN application scenarios

  1. Custom domain: test.higher-cloud.com (successful, but please note that this domain is a CNAME, and DNS resolution will redirect to the AWS default domain).

    Guide to understanding the best practices of CDN application scenarios
 
  1. Next, we will test the webpage speed using a machine located in the AWS US region.

Domain: www.higher-cloud.com
Access method: Direct access to the origin server
Latency: 521ms

Guide to understanding the best practices of CDN application scenarios
Domain: dtytosfxel4su.cloudfront.net
Access method: Accelerated via CloudFront
Latency: 48ms

Guide to understanding the best practices of CDN application scenarios

Domain: test.higher-cloud.com
Access method: DNS CNAME resolution, resolving test.higher-cloud.com to dtytosfxel4su.cloudfront.net, and then resolving back to CloudFront's node
Latency: 102ms

Guide to understanding the best practices of CDN application scenarios

 

Conclusion
From a business perspective, AWS CloudFront offers a highly flexible and fast service. Even if the origin server does not have HTTPS encryption, AWS provides a convenient way to obtain SSL certificates through its platform, allowing website owners to encrypt their sites and thereby improve SEO rankings and brand credibility.

In terms of user experience, CDN also improves connection latency for users. As shown in the above charts, while the latency for connecting to the origin server from the US is around 500ms, it decreases to 50-100ms when using CDN, resulting in a significant improvement in user experience. In terms of usability, CDN services offered by different providers operate similarly, but the quality may vary depending on the global distribution of nodes. Apart from AWS CloudFront demonstrated here, other CDN providers like Google Cloud, Alibaba Cloud, Tencent Cloud, and Cloudflare also offer CDN services.



Author

 

 

Solution Architecture
吳祐德 Ted Wu