All Products
Search
Document Center

Object Storage Service:Use CDN to accelerate access to OSS

Last Updated:Jul 13, 2023

You can use Alibaba Cloud CDN to accelerate access to Object Storage Service (OSS). If you directly access OSS resources, the access speed varies based on the region in which the buckets are located and is limited by the outbound bandwidth of OSS. Alibaba Cloud CDN provides higher bandwidth, caches OSS resources on the points of presence (POPs) nearby, and distributes the resources to users from the POPs. This helps you reduce costs. This topic describes how to use Alibaba Cloud CDN to accelerate access to OSS.

Prerequisites

Background information

With data increasingly accessed, to avoid performance bottlenecks, we recommend that you store static data in OSS and use Alibaba Cloud CDN to accelerate access to OSS. This transforms the traditional website architecture to cloud-based website architecture. The architecture transformation greatly improves the stability and reliability of your website and significantly improves the access speed for the website.

Traditional website architecture

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

传统

This architecture has the following characteristics:

  • Dynamic and static resources are stored on the same server.

  • Users can directly access the server to request data.

The traditional website architecture has the following disadvantages:

  • The web server is overloaded.

    Dynamic data and static data share the same server. When access to the website increases, the server may not be able to accommodate the high load, which may cause the website to slow down or even crash.

  • Storage space is difficult to expand.

    The storage space of static resources is limited by the hard disk capacity of the server. When storage space is insufficient, hard disks of the server must be expanded or upgraded, which requires additional capital and time.

Cloud-based website architecture

In the cloud-based website architecture, dynamic and static resources are separated. Therefore, the performance of a website is ensured when access to the website increases. The following figure shows the cloud-based website architecture.

动静分离

This architecture has the following characteristics:

  • 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 Alibaba Cloud CDN and distributes objects cached on the POPs closest to the regions in which users are located to accelerate data access.

This architecture provides the following benefits:

  • Reduced web server workload

    OSS resources are cached on and distributed from the POPs closest to users. This way, data access is accelerated because the transmission distance is decreased.

  • Unlimited storage

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

  • Reduced storage and traffic costs

    In this architecture, you are charged storage fees for storing data in OSS buckets, outbound traffic fees for CDN, and a small amount of origin traffic fees. The storage fees for storing data in 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.

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 root domain, second-level domain, or wildcard domain name.

Step 1: Add and resolve a domain name

Quick deployment

You can use Resource Orchestration Service (ROS) to add a domain name that you want to accelerate and resolve the domain name to CNAME assigned by Alibaba Cloud CDN. To use ROS to add and resolve a domain name, perform the following steps:

  1. Go to the Use New Resources wizard in the ROS console.

  2. In the Configure Template Parameters step of the Use New Resources (Standard) wizard in the Resource orchestration ROS console, specify the domain name (oss.example.com in this example) that you want to accelerate in the Accelerated domain name field, specify the public domain name of the bucket whose resources you want to access in the Source station information field, and click Create.

    On the Stack Information tab of the page that appears, the status of the stack is Creating.

  3. After the status of the stack becomes Created, click the Outputs tab to view the CNAME.

Manual deployment

  1. Add the domain name that you want to accelerate.

    1. Log on to the Alibaba Cloud CDN console. In the left-side navigation pane, 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 Image and Small File.

      • Region: Select Chinese Mainland Only.

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

    3. Click Next, and then click Return to Domain Name List.

    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. In the Actions column of the domain name example.com, click Resolve.

    2. On the DNS Settings page, click Add DNS Record. In the Add DNS Record panel, configure the following parameters:

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

      • Hostname: Enter oss.

      • Record 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 the result is similar to the result that is shown in the following figure, the accelerated domain name takes effect.

      ping

Step 2: 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. In the left-side navigation tree, choose Bucket Settings > Domain Names.

  3. Enable Auto CDN Cache Update for the accelerated domain name that you added.

Step 3: View the URL of the 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.

  2. In the left-side navigation tree, choose Files > Objects. On the Objects page, find the object and click View Details in the Actions column.

  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 Alibaba Cloud CDN.

    海龟

Step 4: Specify that the URL of the object is permanently valid

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

  2. Select Public Read, and click OK.

Step 5: (Optional) Configure an SSL certificate for encrypted access

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

  2. Log on to the Alibaba Cloud CDN console. In the left-side navigation pane, click Domain Names. On the Domain Names page, click the accelerated domain name.

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

  4. After you complete the settings, access the object over HTTPS. For more information, see Configure an SSL certificate.

Cost saving

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