All Products
Search
Document Center

Use CDN to accelerate access to OSS

Last Updated: Jul 20, 2021

When you access Object Storage Service (OSS) resources, the access speed depends on the region in which the buckets are located and is limited by the downstream bandwidth of OSS. Alibaba Cloud Content Delivery Network (CDN) provides higher bandwidth. If you use CDN to access OSS resources, CDN caches the resources on CDN nodes closest to your region and distributes the resources to you from the nodes. This way, you can access OSS resources more quickly at lower costs. This topic describes how to use CDN to accelerate access to OSS.

Background information

In traditional website architectures, dynamic and static resources are not separated. Therefore, the performance of a traditional website is bottlenecked when access to the website grows. The following figure shows a traditional website architecture.

Traditional website architecture

You can use an architecture in which dynamic and static resources are separated to resolve the performance problem when the website is accessed by a large number of users. The following figure shows an architecture in which dynamic and static resources are separated.

Architecture in which dynamic and static resources are separated

This architecture separates and distributes resources in the following methods:

  • Stores dynamic resources such as web applications and databases on Elastic Compute Service (ECS) instances.

  • Stores static resources such as images, video and audio files, and static scripts in OSS buckets.

  • Uses OSS buckets as the origins of CDN and distributes objects cached on the node closest to the region in which the user is located to accelerate data access.

This architecture has the following benefits:

  • The workload for web servers is reduced.

    OSS resources are cached on and distributed from CDN nodes closest to the regions in which users are located. This way, data access is accelerated because the transmission distance is minimized.

  • The storage of a large amount of data is supported.

    The capacity of OSS buckets can be elastically expanded. You do not need to upgrade your storage architecture.

  • Storage fees and traffic fees are reduced.

    In this architecture, you are charged the storage fees for OSS buckets, downstream traffic fees for CDN, and a small amount of back-to-origin traffic fees. The storage fees for OSS buckets are 50% cheaper than those for the same capacity of cloud disks. The unit price of CDN traffic is only about 30% to 40% of the unit price of OSS outbound traffic over the Internet.

Prerequisites

Procedure

In the following steps, example.com is used as the domain name and oss.example.com is used as the accelerated domain name. You can specify an actual domain name as the accelerated domain name, such as a primary domain, second-level domain, or wildcard domain name.

  1. Add a domain name.

    1. Log on to the DCDN console. Click Domain Names.

    2. Click Add Domain Name. On the page that appears, configure the following parameters:

      • Domain Name to Accelerate: Enter the domain name that you want to specify as the accelerated domain name. In this example, enter oss.example.com.

      • Business Type: Select DCDN.

      • Acceleration Region: Select Mainland China Only.

      • Origin Information: Select Add Origin Server. On the dialog box that appears, select OSS Domain for Type, and then select the domain name of the bucket for which you want to accelerate access from the drop-down list. Keep the default settings of other parameters. Click OK.

    3. Click Next. Then, click Return.

    4. Wait until the status of the domain name becomes Running. Copy the CNAME of the domain name, which is oss.example.com.w.kunluncan.com in this example.

  2. Resolve the domain name.

    1. Log on to the Domains console. Click Resolve in the Actions column that corresponds to the domain name example.com.

    2. On the Add Record page, configure the following parameters:

      • Record Type: Select CNAME from the drop-down list.

      • Host: Enter oss.

      • Value: Enter the copied CNAME oss.example.com.w.kunluncan.com.

      • Other parameters: Keep the default settings.

    3. Click OK. Wait a few minutes, and then run the ping command to check whether the accelerated domain name takes effect. If a similar result showed in the following figure is returned, the accelerated domain name takes effect.

      ping
  3. Enable auto CDN cache update

    1. Log on to the OSS console. In the left-side navigation pane, click Buckets. On the Buckets page, click the name of the bucket for which you want to accelerate access.

    2. Choose Transmission > Domain Names.

    3. Turn on Auto CDN Cache Update for the accelerated domain name that you add.

  4. View the URL of an object.

    1. Log on to the OSS console. In the left-side navigation pane, click Buckets. On the Buckets page, click the name of the bucket in which the object you want to view is stored.

    2. Click Files. On the page that appears, click View Details in the Actions column that corresponds to the object that you want to view.

    3. In the View Details panel, select the accelerated domain name from the Custom Domain Name drop-down list. In this example, select oss.example.com. As shown in the following figure, the URL of the object starts with the accelerated domain name.

      url
    4. Access the object by using the URL and use the developer tools of your browser to view the details. The following figure shows that the accelerated domain name takes effect and the object is cached on CDN.

      Turtle
  5. Remove the validity period of the URL.

    1. In the View Details panel, click Set ACL.

    2. Select Public Read. Click OK.

  6. (Optional) Configure HTTPS certificates used to access the object.

    1. In the View Details panel of the object, turn on HTTPS.

    2. Log on to the DCDN console. Click Domain Names. On the page that appears, click the accelerated domain name that you add.

    3. In the left-side navigation pane, click HTTPS Settings. In the SSL Certificate section, click Modify.

    4. After you complete the settings, you can access the object by using HTTPS. For more information, see Configure HTTPS certificates.

Purchase resource plans

To further reduce the cost, click OSS Resource Plan and CDN Resource Plan to purchase resource plans.