Alibaba Cloud Content Delivery Network (CDN) can cache static resources stored on Elastic Compute Service (ECS) instances to accelerate the delivery of the resources. The resources stored on ECS instances include static resources and dynamic resources. When a client requests dynamic resources from an ECS instance, the ECS instance returns the requested resources to the client. When a client requests static resources from an ECS instance, if the CDN node closest to the client has cached the requested resources, the CDN node returns the cached resources to the client. In this way, the delivery of the static resources is accelerated. This topic describes the scenario where CDN integrates with ECS and how to configure the acceleration in the CDN console.

Prerequisites

Before you perform the tasks described in this document, make sure that you have completed account registration and real-name authentication with Alibaba Cloud.

Background information

Alibaba Cloud CDN works with a precise scheduling system. The system redirects requests for static resources to the edge nodes closest to the end users who make the requests. This mechanism enables efficient retrieval of required resources, and minimizes network congestion.

An ECS instance stores dynamic resources such as Web applications and databases, and static resources such as static scripts, images, attachments, audio files, and video files. CDN nodes cache static resources rather than dynamic resources from the ECS instance. When a client requests to access or download dynamic resources, the ECS instance returns the requested resources to the client. When a client requests the cached static resources, the scheduling system redirects the request to the edge node closest to the client. Then, this edge node returns the cached resources to the client. The following figure shows the architecture of integrating CDN with an ECS instance.Scenario
This architecture provides the following benefits:
  • All requests to the origin server are sent to CDN nodes. This reduces the pressure on the origin server.
  • Compared with the resources returned by the ECS instance, the resources returned by CDN nodes incur a lower outbound data transfer fee.
  • The client retrieves static resources from the closest CDN node. This minimizes the network transmission distance and ensures the quality of retrieved resources.

The following section describes how to add a Canonical Name (CNAME) record in the Alibaba Cloud Domain Name System (DNS) console.

Procedure

  1. In the CDN console, add a CDN domain for the ECS instance.
    1. Log on to the CDN console.
    2. In the left-side navigation pane, click Domain Names.
    3. On the Domain Names page, click Add Domain Name.
    4. Select IP or Origin Domain in the Origin Info section, and complete other required settings. The following table describes the parameters for adding a CDN domain.
      Parameter Option Description
      Domain Name to Accelerate N/A
      Enter a domain name, for example, ch.aliyun.com. Follow these rules:
      • You can use a subdomain name or a wildcard domain name as the accelerated domain name, for example, cdntest.example.com.
      • Wildcard domains are supported and Chinese domains are not supported. Follow the instructions to enter a wildcard domain name, for example, *.test.com. For more information about how to add a wildcard domain name, see Rules for adding wildcard domain names.
      • You cannot add a domain name to Alibaba Cloud CDN more than once. If a DomainAlreadyExist error occurs, submit a ticket.
      • Up to 50 domains can be added to Alibaba Cloud CDN under each account. To add more domains, submit a ticket.
      • Content that is served from the domain must comply with the limits of Alibaba Cloud CDN. For more information, see Limits.
      Business Type Image and Small File If you want to accelerate the delivery of small-sized static content on your website, such as small files, images, and style sheets, we recommend that you select Image and Small File from the Business Type drop-down list.
      Large File Download If you want to accelerate the delivery of static files that are larger than 20 MB, such as game installation packages, app updates, mobile read-only memory (ROM) upgrades, and app package downloads, we recommend that you select Large File Download from the Business Type drop-down list.
      VOD If you want to accelerate the delivery of on-demand video or audio content, we recommend that you select VOD from the Business Type drop-down list.
      DCDN If your website or application contains large amounts of dynamic content, you can select DCDN from the Business Type drop-down list. With simple configurations, Dynamic Route for CDN (DCDN) can accelerate the delivery of dynamic and static content separately. Static content is cached and dynamic content is retrieved from the origin based on the optimal link algorithm and protocol layer optimization of Alibaba Cloud.

      After you select DCDN, you are prompted to go to the Dynamic Route for CDN console. You can then create and configure the accelerated domain. For more information.

      Origin Info IP You can specify the public IP addresses of one or more servers. IP addresses of Alibaba Cloud Elastic Compute Service (ECS) instances are exempt from manual review.
      Site Domain You can specify the domain names of one or more publicly accessible origin servers.
      Note The domain name of the origin server cannot be the same as the accelerated domain name. Otherwise, a DNS resolution loop occurs, and the requests cannot be forwarded to the origin server correctly. For example, if you set the accelerated domain name to cdn.yourdomain.com, you can set the origin domain name to img.yourdomain.com.
      OSS Domain You can manually enter the Internet domain name of an Alibaba Cloud Object Storage Service (OSS) bucket, for example, xxx.oss-cn-hangzhou.aliyuncs.com. To view the Internet domain name of an OSS bucket, go to the OSS console. You can also directly select an OSS bucket under the same account.
      Function Compute Domain You must set the Region and Domain Name parameters of the Function Compute domain. For more information, see Set a Function Compute domain name.
      Port N/A
      Select a port as needed.
      • Port 80

        Specifies access to resources over HTTP.

      • Port 443

        Specifies access to resources over HTTPS.

      Region Outside Mainland China If you select Outside Mainland China, no Internet content provider (ICP) filing is required.
      Global If you select Global, you must apply for an ICP filing with the Ministry of Industry and Information Technology (MIIT) of China. For more information, see Domain filing.
      Mainland China If you select Mainland China, you must apply for an ICP filing with the MITT of China. For more information, see Domain filing.
      domain
    5. Click Next.
      After your CDN domain is reviewed and approved, you can view the domain name on the Domain Names page in the CDN console. The added domain is displayed in the Enabled state.domain complete
  2. Log on to the CDN console and obtain the CNAME of the CDN domain.
    1. In the left-side navigation pane, click Domain Names.
    2. On the Domain Names page, copy the CNAME domain of your accelerated domain.
      Domain names
  3. In the Alibaba Cloud DNS console, add a CNAME record.
    1. Log on to the Alibaba Cloud DNS console.
    2. On the Manage DNS page, click the Domains tab, select a domain, and then click Configure in the Actions column for the domain.
      DNS Settings
    3. Click Add Record to add a CNAME record.
      • Type: Select CNAME from the drop-down list.
      • Host: Enter the prefix of the accelerated domain.
        Accelerated domain Host
        testcdn.aliyun.com testcdn
        www.aliyun.com www
        aliyun.com @
        *.aliyun.com *
      • ISP Line: Use the default value.
      • Value: Enter the CNAME domain that you have copied in step 1.
      • TTL: Use the default value.
      Record
    4. Click OK.
      The CNAME record is added. Immediately after you add the record on Alibaba Cloud DNS, the CNAME record takes effect, and the CDN service is automatically enabled.
      Note
      • If you modify the CNAME record, the record takes effect within 72 hours after the modification.
      • After you add a CNAME record, it takes approximately 10 minutes to update the status in the console. The message "You must add the CNAME record" may still appear on the Domain Names page. Ignore this message.
  4. On a local computer, check whether the CNAME record works as expected.