Background
More and more companies in various industries use OBS to store static resource files such as images, videos, and software packages, and use OBS as the storage source for websites, forums, apps, and games. You can directly request these static resources from OBS using URLs. Figure 1 shows the request process. OBS can solve the problem of insufficient local storage. Generally, files are stored in only one region. The response speeds for users accessing OBS in different regions are different. In scenarios where frequent access is required, accessing OBS to obtain files consumes a large amount of traffic.
Figure 1 Process of obtaining data from OBS
Solution Description
OBS provides low-cost storage, and Huawei Cloud CDN provides website acceleration, file download acceleration, and on-demand service acceleration. Storing data on OBS and using CDN for service acceleration can both reduce costs and improve user experience. When a user initiates an access request, CDN searches for the CDN PoP with the fastest response speed and checks whether the content requested by the user is cached on the CDN PoP.
If the CDN PoP does not cache the requested data or the cached data expires, CDN retrieves the content from OBS, as shown in Figure 2.
Figure 2 Accessing OBS with CDN acceleration (without cached data on the CDN PoP)
When another user accesses the same data, CDN directly returns the cached data to the user without sending another access request to OBS. Figure 3 shows the process of accessing OBS using CDN when the CDN PoP caches the desired content.
Figure 3 Accessing OBS with CDN acceleration (with cached data on the CDN PoP)
Solution Advantages
- Low cost: OBS provides pull traffic packages with preferential prices for CDN to pull content from OBS. When data is cached on CDN PoPs, subsequent requests are charged based on the pull traffic consumed by CDN, which reduces OBS costs.
- High efficiency: The CDN service on Huawei Cloud has sufficient acceleration resources and widely distributed nodes. It ensures that user requests are precisely scheduled to the optimal edge node to provide effective and stable acceleration effects.
Application Scenarios
- Applications or services that provide file download services through OBS. For example, websites, game clients, and app stores that provide file download services based on HTTP or HTTPS.
- Applications or services that provide audio on demand (AOD) or video on demand (VOD) services through OBS. For example, online education websites, online video sharing websites, Internet VOD platforms, and AOD or VOD apps.
Constraints
Only buckets of version 3.0 or later support CDN acceleration. To check the version of a bucket, you need to go to the Basic Information area on the Overview page of the bucket on OBS Console.
Using CDN to Accelerate OBS-Based VOD
The following describes the CDN acceleration solution for OBS-based VOD and covers the scenarios, architecture, advantages, constraints, resource planning, and procedures.
Scenarios
Traditional VOD services put a heavy load on servers and consume great bandwidth. Low-speed services compromise user experience.
Storing data on OBS and using CDN for service acceleration can both reduce costs and improve user experience.
The CDN acceleration solution is suitable for customers that provide AOD or VOD services, such as online education websites, online video sharing websites, Internet VOD platforms, and AOD or VOD apps.
Solution Architecture
Figure 4 VOD acceleration architecture
- A customer configures an acceleration domain name on the CDN console.
- User A sends a request using a browser or an app. DNS resolves the request and forwards it to a CDN PoP.
- The CDN PoP pulls the data from an OBS bucket. OBS returns the data to the CDN PoP.
- The CDN PoP returns the data to user A.
- User B sends a request for accessing the same data using a browser or an app. DNS resolves the request and forwards it to a CDN PoP.
- The CDN PoP has cached data and directly returns the requested data to user B.
Advantages
- OBS is secure, highly reliable, and cost-effective. It can be used to reduce storage costs.
- CDN PoPs are distributed across different regions. CDN PoPs cache audio and video content close to end users, providing them a smoother AOD and VOD experience.
- Huawei Cloud CDN and OBS are connected through the intranet, reducing bandwidth costs.
In conclusion, customers can provide better VOD services for end users at lower costs.
Resource and Cost Planning
The following table describes the resource and cost planning in this best practice.
Table 1 Resource and cost planning Dimensions | Description |
|---|
Resource planning | Mandatory - OBS: provides buckets for storing static resources such as images and software packages. You need to set the bucket storage class to Standard or Infrequent Access and the bucket policy to private. (CDN acceleration cannot be configured for buckets in the Archive, or Deep Archive storage class.)
- CDN: accelerates on-demand services.
- DNS: You need to add a CNAME record set through your DNS provider so that the acceleration domain name points to its corresponding CNAME domain name in CDN. After the DNS change takes effect, all requests to the acceleration domain name will be routed to CDN PoPs.
- Website domain name: According to China's Internet Management Regulations, the domain name must be licensed by the Ministry of Industry and Information Technology (MIIT) and the license has not expired. Otherwise, CDN cannot provide the acceleration service for the domain name.
|
Cost planning | Mandatory Optional Pull traffic packages: CDN consumes traffic when it pulls data from OBS. OBS provides pull traffic packages, which can reduce the traffic costs incurred by data retrieval. NOTICE: The price provided is for reference only. The actual price is the one displayed on the Huawei Cloud console. |
Procedure
- (Optional) Purchase pull traffic packages.
CDN consumes traffic when it pulls data from OBS. OBS provides pull traffic packages, which can reduce the traffic costs incurred by data retrieval. If no pull traffic package is purchased, you will be billed for outbound Internet traffic on a pay-per-use basis.
- Go to the Buy OBS Package page.
- Configure the following parameters based on your service demands.
- Region: Select the region where the bucket for which CDN acceleration is to be configured is located.
- Package Type: Select Traffic packages and then Pull traffic.
- Monthly Traffic: Select a quota based on your actual needs.
- Quantity: Enter the number of pull traffic packages that you want to buy. For example, if you purchase two pull traffic packages with 1 TB monthly quota each, you will get 2 TB pull traffic each month.
- Required Duration: Select a duration for the packages.
- Effective: You can choose Immediately to make the package take effect right after payment or choose Custom to define when it becomes effective.
- Click Next.
- Configure CDN to accelerate the on-demand service.
OBS supports domain name management. A user-defined domain name can be bound to OBS, enabling access through that domain. You can also configure CDN acceleration during the binding.
- Log in to OBS Console.
- Click the bucket where the software package is stored, for example, the bucket named my-video.
- In the navigation pane, choose Basic Configurations > Domain Name Mgmt and click Configure Acceleration Domain Name.
- In the Configure Acceleration Domain Name dialog box, configure CDN acceleration information, as shown in Figure 5.
- Service Area: Select the service area as required.
- Business Type: Select Video on demand.
- Bucket: Select Private bucket.
- Acceleration: Enter the domain name of the video website, for example, click.my-video.com.
Figure 5 Configuring an acceleration domain name
- Click OK.
- Add a CNAME record set.
After a user-defined domain name is bound to OBS and CDN acceleration is configured for the user-defined domain name, CDN automatically generates a CNAME domain name. You need to add a CNAME record set through your DNS provider so that the acceleration domain name is pointed to its corresponding CNAME domain name in CDN. After the domain name resolution takes effect, all requests for the acceleration domain name will be directed to CDN PoPs. In this example, the automatically generated CNAME domain name is click.my-video.com.c.cdnhwc1.com.
The CNAME record set configuration varies depending on DNS providers. In this document, DNS provided by Huawei Cloud is used as an example. For details about how to configure CNAME records with other DNS providers, see
Configuring a CNAME Record.
- Log in to the DNS console.
- In the navigation pane, choose Public Zones.
- Click the domain name to which you want to add a record set. In this example, the domain name is my-video.com.
- Click Add Record Set.
- Configure the parameters based on Table 2. Retain the default values for those not listed in the table below.
Table 2 Parameters Parameter | Description | Example Value |
|---|
Type | Type of the record set, which should be the CNAME type. | CNAME – Map one domain to another |
Name | Prefix of the domain name | click |
Line | Resolution line. The DNS server will return the IP address of the specified line, depending on where the visitor comes from. You must add a Default line to ensure that the website is accessible to anyone. | Default |
TTL (s) | TTL is the length of time for which a local DNS server caches a record set. If your service address changes frequently, set TTL to a smaller value. Otherwise, set TTL to a larger value. | Default value: 300 |
Value | Domain name to be pointed to If CDN acceleration is not enabled, set this parameter to the bucket domain name. If CDN acceleration is enabled, set this parameter to the CNAME domain name allocated by CDN. | click.my-video.com.c.cdnhwc1.com |
Alias | Whether you want this record set to be used as an alias for a Huawei Cloud service resource | Keep it disabled. |
- Click OK.
- Verify that the added CNAME record set is in effect.
Open the Windows command line interface and run the following command:
nslookup -qt=cname User-defined domain name bound to the bucket
In this example, the user-defined domain name bound to the bucket is click.my-video.com. If the output is the CNAME domain name allocated by CDN, the CNAME record set is in effect.
- Configure the URL of the on-demand service.
Set the URL of the file that requires on-demand acceleration in the code as follows: <domain-name-of-the-video-website>/<file's-storage-path-in-the-OBS-bucket>/file-name.
In the following example, the video website domain name is click.my-video.com, as configured in 2, and the introduction.mp4 file under the video/3.2.1/ folder in the my-video bucket is used as an example. Then the file URL is as follows:
https://click.my-video.com/video/3.2.1/introduction.mp4
- Grant permissions to an IAM agency to prevent objects in the private bucket from being listed by anonymous users.
After private bucket retrieval is configured, any anonymous user who accesses the bucket through the user-defined domain name (CDN acceleration domain name) can list objects in the root directory of the bucket. As a result, the object list is exposed to the public network. If you do not want anonymous users (users who are not authenticated or authorized) to list objects in your bucket, you need to create a policy for the CDNAccessPrivateOBS agency to deny listing objects in the bucket. For more information, see Why Are All Files in the Bucket Displayed When Users Request a File from an OBS Bucket Connected to CDN?

- If it is the first time you set a private OBS bucket as the origin server of a domain name, you need to enable OBS authorization on the CDN console to authorize CDN to access your OBS private buckets. For details, see OBS Authorization.
- With OBS authorization, the system automatically creates an agency named CDNAccessPrivateOBS.
- In the navigation pane of the IAM console, choose Agencies. In the Operation column of CDNAccessPrivateOBS, click Authorize.
- On the Authorize Agency page, click Create Policy and set the parameters as follows.
Table 3 Parameters Parameter | Description |
|---|
Policy Name | Enter a custom policy name, for example, deny ListBucket. |
Policy View | Select Visual editor. |
Policy Content | Effect | Select Deny. |
Select service | Select Object Storage Service (OBS). |
Select action | Select obs:bucket:ListBucket. |
(Optional) Select resource | Select All. |
(Optional) Add request condition | - |
- Click Next.
- On the displayed page, select the created policy, for example, deny ListBucket, and click Next.
- On the displayed page, click OK. The authorization takes effect 15 to 20 minutes later.
- After the authorization takes effect, refresh the CDN cache and try again.
- Verify the services.
After the video website is redeployed, log in to the video website and play a video.
If the video can be played, the acceleration configuration is successful.