You can use Alibaba Cloud Content Delivery Network (CDN) to accelerate the delivery of static resources on an Elastic Compute Service (ECS) instance. Users directly retrieve dynamic resources from the ECS instance. Static resource on the ECS instance are cached on CDN nodes that are globally distributed. Users can retrieve static resources from the nearest CDN nodes. This accelerates the delivery of resources on the ECS instance. This topic describes how to enable Alibaba Cloud CDN to accelerate the delivery of resources on ECS instances in the Alibaba Cloud CDN console and the use scenarios of Alibaba Cloud CDN.

Background information

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 static resources that are cached on CDN nodes, the scheduling system redirects the request to the CDN node nearest to the client. Then, the CDN node returns the cached resources to the client. The following figure shows how Alibaba Cloud CDN accelerates the delivery of resources on an ECS instance.
Note If you want to accelerate the delivery of dynamic resources on an ECS instance, use Dynamic Route for CDN (DCDN). For more information, see What is DCDN?
Use scenario
In this case, the ECS instance is the origin server. The delivery of content stored on the ECS instance is accelerate by Alibaba Cloud CDN. Users retrieve files from the nearest CDN nodes. This architecture provides the following benefits:
  • All requests destined for the origin server are redirected to CDN nodes. This reduces loads on the origin server.
  • Compared with data transfer between clients and ECS instances over the Internet, data transfer between clients and CDN nodes is billed at a lower price.
  • Clients retrieve static resources from the nearest CDN nodes. This minimizes the network transmission distance and ensures the quality of the retrieved resources.

Procedure

  1. In the Alibaba Cloud CDN console, add the ECS instance as the origin server.
    1. Log on to the Alibaba Cloud CDN console.
    2. In the left-side navigation pane, click Domain Names.
    3. On the Domain Names page, click Add Domain Name.
    4. On the Add Domain Name page, set the following parameters.

      Step 1: Set the basic information about the origin server

      intl
      Parameter Description
      Domain Name to Accelerate
      Take note of the following rules:
      • The domain name to be accelerated can be a subdomain name or a wildcard domain name. The domain name must be in lowercase letters. Chinese characters are not supported.

        If the domain name is example.com, the domain name to be accelerated can be a subdomain name of example.com, for example, cdntest.example.com.

      • You can specify a wildcard domain name, such as *.example.com. For more information about the rules for adding wildcard domain names, see Rules for adding wildcard domain names.
        Note
        • The specified wildcard domain name and the domain names that match the wildcard domain name must belong to the same Alibaba Cloud account. When you add a domain name to Alibaba Cloud CDN, Alibaba Cloud CDN verifies the ownership of the domain name. If the specified wildcard domain name and the domain names that match the wildcard domain name belong to different Alibaba Cloud accounts, an error message appears. To request technical support from Alibaba Cloud, submit a ticket.
        • If a wildcard domain name is not added to Alibaba Cloud CDN, you can add domain names that match the wildcard domain name to Alibaba Cloud CDN by using different Alibaba Cloud accounts.
      • You cannot add duplicate domain names to Alibaba Cloud CDN.

        If a DomainAlreadyExist error occurs, check whether the domain name is already added to other Alibaba Cloud services such as ApsaraVideo VOD, ApsaraVideo Live, Dynamic Route for CDN (DCDN), Secure CDN (SCDN), and Video Surveillance. You can also submit a ticket to report this issue.

      • You can add at most 50 domain names to Alibaba Cloud CDN with each Alibaba Cloud account.

        However, if the sum of the average daily peak bandwidth values of your domain names exceeds 50 Mbit/s, you can submit a ticket to add more domain names to Alibaba Cloud CDN. Make sure that the increase of domain names does not cause business risks.

      • The content delivered from the domain name must be legal and comply with the Terms of Service for Alibaba Cloud CDN. For more information, see Limits.
      Business Type
      • Image and small file distribution: accelerates the delivery of small-sized static content on websites, such as e-commerce content and game images.
      • Large file distribution: accelerates the delivery of static files that are larger than 20 MB.
      • On-demand audio and video streaming: accelerates the delivery of audio or video files.
      • What is DCDN?: accelerates the delivery of both static and dynamic content. DCDN can accelerate the delivery of large amounts of dynamic content.

        If you set Business Type to DCDN, you must follow the instructions to go to the DCDN console to add and configure the domain name. For more information, see Add a domain name.

      Region
      Select an accelerated region. If you select Mainland China Only or Global, you must apply for an ICP number for the domain name. We recommend that you use Alibaba Cloud ICP Filing System to apply for ICP numbers. It may take some time for Ministry of Industry and Information Technology (MIIT) to update data in the database. After you submit domain name information to MIIT, we recommend that you wait 8 hours before you configure the domain name in Alibaba Cloud CDN.
      Note The pricing strategies vary based on the accelerated region. Choose an accelerated region based on your business requirements. For more information about the pricing of Alibaba Cloud CDN, see CDN Pricing.
      • Mainland China Only: All requests are scheduled to CDN nodes that are deployed in mainland China. Requests from outside mainland China are scheduled to CDN nodes managed by China Telecom (East China Division).
      • Global: All requests are scheduled to the nearest CDN nodes.
      • Global (Excluding Mainland China): All requests are scheduled to CDN nodes that are deployed in Hong Kong (China), Macao (China), Taiwan (China), or other countries or regions outside mainland China. However, requests from mainland China are scheduled to CDN nodes that are deployed in Japan, Singapore, or Hong Kong (China).
      Step 2: Configure the origin server Configure the origin server
      Parameter Description
      Origin Info Select IP or Site Domain.
      • IP: Enter the public IP address of your server. You can enter multiple IP addresses.
      • Site Domain: Enter the domain name of your origin server. You can enter multiple domain names.
        Note The domain name of the origin server cannot be the same as the domain name to be accelerated. Otherwise, a DNS resolution loop occurs and requests cannot be redirected to the origin server.
      Priority

      You can set priorities to specify primary and secondary origin servers. The primary origin server has a higher priority than a secondary origin server. Alibaba Cloud CDN preferably redirects requests to the primary origin server.

      For example, you have specified two origin servers: Server A and Server B. Server A is the primary origin server and Server B is a secondary origin server. In this case, Alibaba Cloud CDN preferably redirects requests to Server A. If Origin Server A fails, Alibaba Cloud CDN redirects user requests to Origin Server B. After Origin Server A recovers, Alibaba Cloud CDN fails back to Origin Server A.

      Weight

      If the origin servers have the same priority, Alibaba Cloud CDN redirects requests to the origin servers based on their weights. This balances loads among the origin servers. The valid values of origin server weights are 1 to 100. A greater value indicates a higher priority. An origin server with a higher weight receives more user requests. The default weight is 10. You can specify a weight based on your business requirements.

      For example, both Origin Server A and Origin Server B are specified as primary origin servers. The weight of Origin Server A is 80 and the weight of Origin Server B is 20. In this case, Alibaba Cloud CDN redirects user requests to both origin servers at a ratio of 8:2.

      Port
      The default port is port 80. You can specify a port based on the settings of your origin server. Valid values are 1 to 65535. Custom ports support only HTTP. If you want Alibaba Cloud CDN to redirect HTTPS requests to origin servers over custom ports, submit a ticket.
      • If you specify a custom port, disable the origin protocol policy. Otherwise, the specified port cannot take effect. For more information, see Configure the origin protocol policy.
      • If the origin server is an OSS bucket, OSS determines whether you can specify a custom port.
    5. Optional. Click Next.
      If this is the first time the domain name is added to Alibaba Cloud CDN, Alibaba Cloud CDN must verify the ownership of the domain name. If the domain name has already passed the verification, skip this step. For more information, see Verify the ownership of a domain name.
    6. Wait for manual review.
      Note If the domain name does not need to be manually verified, proceed to the next step. In the next step, you can set the parameters based on your business requirements.

      It takes one to two business days to verify the ownership of a domain name. If the origin server is an ECS instance or an OSS bucket, you can submit a ticket. It takes less time to verify the ownership of an ECS instance or an OSS bucket.

      After the domain name passes the verification, you can check the status of the domain name on the Domain Names page. If the domain name is in the Enabled state, it indicates that the domain name is added to Alibaba Cloud CDN.

  2. Log on to the Alibaba Cloud CDN console and obtain the CNAME assigned to the domain name.
    1. Log on to the Alibaba Cloud CDN console.
    2. In the left-side navigation pane, click Domain Names.
    3. On the Domain Names page, copy the CNAME of the domain name to be accelerated.
      Domain Names
  3. In the Alibaba Cloud DNS console, add a CNAME record for the domain name.
    In the following example, Alibaba Cloud DNS is used to demonstrate how to configure a CNAME record.
    1. Log on to the Alibaba Cloud DNS console with the Alibaba Cloud account to which the domain name belongs.
    2. On the Manage DNS page, find the domain name that you want to manage and click Configure in the Actions column.
      Note If the domain name is not registered through Alibaba Cloud Domains, you must add the domain name to Alibaba Cloud DNS before you can add a DNS record for it. For more information, see Domain management.
    3. Click Add Record and add a CNAME record.
      Note
      • The CNAME record of a specific domain name takes precedence over that of a wildcard domain name. If the domain name to be accelerated is a wildcard domain name, and the host record includes an asterisk (*), you must delete all effective DNS records of the second-level domain names that match the wildcard domain name.
      • If the CNAME record that you want to use conflicts with an existing DNS record, use another domain name or modify the existing DNS record.
      Add a CNAME record
      Parameter Description Example
      Type Select CNAME from the drop-down list. CNAME
      Host Enter the prefix of the domain name.
      • If the domain name to be accelerated is testcdn.aliyun.com, enter testcdn.
      • If the domain name to be accelerated is www.aliyun.com, enter www.
      • If the domain name to be accelerated is aliyun.com, enter @.
      • If the domain name to be accelerated is *.aliyun.com, enter *.
      ISP Line Enter the default Internet service provider (ISP) line. Keep the default setting.
      Value
      Enter the CNAME of the domain name.
      Note Each accelerated domain name is assigned a unique CNAME. Second-level domain names cannot use the CNAME of the top-level domain name. If you want to accelerate a second-level domain name, add the second-level domain name to Alibaba Cloud CDN. Alibaba Cloud then assigns a CNAME to the second-level domain name. Alternatively, you can add a second-level wildcard domain name to Alibaba Cloud CDN. Domain names that match the wildcard domain name are mapped to the CNAME of the wildcard domain name. For more information, see Add a domain name to Alibaba Cloud CDN.
      all.example.com.w.kunlunsl.com
      TTL Enter a time-to-live (TTL) value for the CNAME record. A smaller value indicates a shorter period of time to apply record updates. The default TTL value is 10 minutes. Keep the default setting.
    4. Click OK.
      After the CNAME record takes effect, acceleration is immediately enabled for the domain name. Newly added CNAME records take effect immediately. By default, it takes 10 minutes for a modified CNAME record to take effect because the default TTL value of a CNAME record is 10 minutes. The time period varies based on the TTL value that you specify for the CNAME record. After you add a CNAME record, it takes about 10 minutes for the system to update the status in the console. The system may prompt that you must add a CNAME record. Ignore the message.
  4. Use an on-premises machine to check whether the CNAME record takes effect.
    1. Open Command Prompt in Windows.
    2. Run the ping command to ping the domain name. If the CNAME in the output is the same as the CNAME that is assigned to the domain name, it indicates that acceleration is enabled for the domain name.
      Check whether the CNAME record takes effect