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
An OSS bucket is created. Resources are uploaded to the bucket. For more information, see Upload objects.
Alibaba Cloud CDN is activated. For more information, see Activate Alibaba Cloud CDN.
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
Cloud-based website architecture
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:
Go to the Use New Resources wizard in the ROS console.
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.
After the status of the stack becomes Created, click the Outputs tab to view the CNAME.
Manual deployment
Add the domain name that you want to accelerate.
Log on to the Alibaba Cloud CDN console. In the left-side navigation pane, click Domain Names.
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.
Click Next, and then click Return to Domain Name List.
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.
Resolve the domain name.
Log on to the Domains console. In the Actions column of the domain name example.com, click Resolve.
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.
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.
Step 2: Enable auto CDN cache update
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.
In the left-side navigation tree, choose
.Enable Auto CDN Cache Update for the accelerated domain name that you added.
Step 3: View the URL of the object
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 the left-side navigation tree, choose Files > Objects. On the Objects page, find the object and click View Details in the Actions column.
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.
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
In the View Details panel, click Set ACL.
Select Public Read, and click OK.
Step 5: (Optional) Configure an SSL certificate for encrypted access
In the View Details panel of the object, turn on HTTPS.
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.
In the left-side navigation pane, click HTTPS Settings. In the SSL Certificate section, click Modify.
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.