Help Center/ Content Delivery Network/ Best Practices/ Accelerating Access to Websites Built on ECSs
Updated on 2024-12-10 GMT+08:00

Accelerating Access to Websites Built on ECSs

Background

An ECS is a basic computing component that consists of CPUs, memory, OS, and Elastic Volume Service (EVS) disks. Flexible ECS configuration helps save a large amount of hardware costs. Assume that a customer deployed a forum website accessible through a domain name on Huawei Cloud ECS. The initial service volume was small, and user access was smooth. As the services grew, the access traffic increased sharply. Users complained about problems such as slow access. To improve the access speed and user experience, the customer decided to use Huawei Cloud CDN.

Solution Overview

Using Huawei Cloud CDN to accelerate content delivery for websites built on ECSs can reduce costs and improve user experience.

Service process: When a user initiates an access request, CDN checks whether the content requested by the user is cached on the CDN PoP with the fastest response speed. If a CDN PoP has cached the content, it directly returns the content to the user. If the CDN PoP does not cache the content, it pulls the content from the origin server, returns the content to the user, and caches the content.

Solution Advantages

  • Users access website content through CDN, reducing the pressure on the origin server.
  • The unit price of CDN traffic is lower than that of the traffic generated when ECSs directly access the Internet, saving 50% to 57% of the bandwidth cost.
  • Users can obtain content from the nearest CDN PoP, which shortens the network transmission distance and ensures the quality of static content.

Procedure

  1. Set up a forum website on an ECS. For details, see Setting Up a Discuz Forum.
    • The IP address of the server is 192.168.1.1.
    • The domain name of the website is discuztest.com.
  2. Enable CDN.
    1. Log in to Huawei Cloud console. Choose Service List > Content Delivery & Edge Computing > Content Delivery Network.

      The CDN console is displayed.

    2. Select a billing option, read and agree to the service agreement, and click Enable Now.
  3. Add a domain name on CDN.
    1. In the navigation pane of the CDN console, choose Domains.
    2. On the Domains page, click Add Domain Names and configure the acceleration domain name and origin server information.
      • Domain Names: Enter discuztest.com.
      • Service Area: Select Chinese mainland.
      • Service Type: Select Website.
      • Origin Server Settings
        • Origin Protocol: Select HTTP.
        • Type: Select IP address.
        • Address: Enter 192.168.1.1.
        • Priority: Select Primary origin server.
        • Host Header: By default, the acceleration domain name is used.

    3. Click OK.

      The configuration takes 5 to 10 minutes to take effect. When Status of the domain name becomes Enabled, the domain name has been added.

  4. Test your domain name before adding a CNAME record to the domain's DNS records to ensure that your domain configurations are correct. For details, see (Optional) Testing the Domain Name.
  5. Configure CNAME resolution. CDN automatically generates a CNAME after you add a domain name. The CNAME cannot be accessed directly. You must add it to your domain's DNS records. Then requests for your domain name will be redirected to CDN PoPs for acceleration.
    In this practice, the generated CNAME is discuztest.com.7fb73989.cdnhwcedi10.com.
    1. In the upper left corner of Huawei Cloud console, choose Service List > Networking > Domain Name Service.

      The DNS console is displayed.

    2. In the navigation pane, choose Public Zones.

      The public zone list is displayed.

    3. Click the domain name you want to add a record set to. In this practice, the domain name is discuztest.com.
    4. Click discuztest.com. On the displayed page, click Add Record Set in the upper right corner. The Add Record Set dialog box is displayed.
    5. Set the parameters as prompted. Use the default values for the parameters that are not listed in the following table.

      Parameter

      Description

      Example

      Name

      Domain name prefix.

      www

      Type

      Type of the record set.

      CNAME – Map one domain to another

      Line

      Resolution line. The DNS server will return the IP address of the specified line based on the source of visitors.

      You must add a Default line to ensure that the website is accessible to users of all carriers.

      Default

      TTL (s)

      Cache duration of the record set on a local DNS server. If your service address changes frequently, set TTL to a smaller value.

      5 min

      Value

      Domain name to be pointed to.

      If CDN acceleration is not enabled, the value is the ECS domain name. If CDN acceleration is enabled, the value is the CNAME generated by CDN.

      discuztest.com.7fb73989.cdnhwcedi10.com

    6. Click OK.
  6. Check whether the CNAME record has taken effect.

    Open the Windows command line interface and run the following command:

    nslookup -qt=cname Acceleration domain name

    In this practice, the acceleration domain name is discuztest.com. If the CNAME generated by CDN is displayed, the CNAME configuration has taken effect.

  7. Check whether the configuration is successful.

    Log in to the forum website and browse web pages. If the website can be visited, the acceleration configuration is successful.