CDN Encyclopedia 11 | How to use CDN to accelerate OSS source site resources

Under the traditional website architecture, dynamic resources and static resources are not separated. As the number of visits increases, performance will become a bottleneck, often facing problems such as slow user response, unsmooth lag, high cost, and poor scalability. Users directly access OSS resources, and the access speed will be limited by the downlink bandwidth of OSS and the bucket area. If you access OSS resources through CDN, the upper limit of bandwidth is higher, and OSS resources can be cached to nearby CDN nodes, and distributed through CDN nodes, the access speed is faster and the cost is lower.

Choose to use Alibaba Cloud CDN to accelerate the OSS domain name and realize the acceleration of static resource access. Today's CDN Encyclopedia introduces the application scenarios of CDN to accelerate OSS and the operation method of CDN to accelerate OSS through the CDN console.

1. Limited time package

In order to meet the needs of most customers, Alibaba Cloud has launched a CDN+OSS combination product package to enjoy exclusive discounts to help users worry about matching, and the package price is as low as 55%.

2. Prerequisites for use

1. Before performing the operations in this article, please make sure that you have completed the Alibaba Cloud account registration  and real-name authentication .
2. Make sure that a storage space has been created on OSS and a custom domain name has been bound to it. For specific operation methods, see Creating Storage Spaces and Binding Custom Domain Names .

3. CDN+OSS architecture and advantages

Alibaba Cloud CDN cooperates with a precise scheduling system to allocate your requests for static resources to the nearest nodes, enabling you to read the required resources as quickly as possible, effectively solving network congestion problems, and improving the response speed of user access.

The static resources stored on the OSS source site include static scripts, pictures, attachments and audio/video. When a terminal user requests to access or download static resources, the CDN accelerates the static resources on the OSS origin site, and the resources on the origin site are cached to the acceleration node of the CDN, and the system automatically calls the cached resources on the CDN node closest to the end user . The accelerated OSS architecture is shown in the figure below.

image.png

As the source of CDN, OSS accelerates the distribution through CDN, and users can obtain files nearby through CDN nodes. The advantages of the architecture are as follows:

1. Users access website resources, all through CDN, reducing the source site pressure.
2. Using CDN traffic, the unit price is lower than OSS direct access to external network traffic.
3. Resources are obtained from the CDN node closest to the client, reducing the network transmission distance and ensuring the quality of static resources.

Next, take Alibaba Cloud DNS as an example to introduce how to configure CNAME.

Four, one of the access methods-complete configuration based on the CDN console

1. On the CDN console, add the OSS domain name.
• Log in to the CDN console .
• In the left navigation bar, click Domain Management.
• On the domain name management page, click Add domain name.
• Fill in the domain name information, and select the OSS domain name as the source site type.

image.png

  1. Click Next.
    When the accelerated domain name is approved, it will appear in the list of domain names managed by the domain name. The status is normal operation, indicating successful addition.

image.png

2. On the CDN console, get the CNAME.

  1. In the left navigation bar, click Domain Management.
  2. Go to the domain name management page and copy the CNAME value corresponding to the accelerated domain name.

image.png

3. Configure CNAME on the Alibaba Cloud DNS console.

  1. Log in to the domain name resolution console.
  2. Enter the domain name resolution page, after the domain name you need to set, click Resolution Settings.
  3. Click Add Record to add a CNAME record.

image.png

  1. Click OK to complete the configuration of CNAME. After the CNAME configuration takes effect, the acceleration service will also take effect immediately.

4. On the local PC, verify that the CNAME configuration takes effect.

  1. Open the Windows CMD command line program.
  2. Ping the accelerated domain name in the command line. If the returned analysis result is consistent with the CNAME value of the accelerated domain name on the CDN console, it means that the CDN acceleration has taken effect.

image.png

5. On the OSS console, turn on the CDN cache automatic refresh switch of the accelerated domain name.

  1. Log in to the OSS management console.
  2. Click the Bucket list in the left navigation bar.
  3. In the bucket list, click the name of the target bucket.
  4. Click Transfer Management> Domain Name Management in the navigation bar of the storage space.
  5. On the domain name management tab, turn on the CDN cache automatic refresh switch of the accelerated domain name.

image.png

Next steps

After the CNAME configuration takes effect, if you directly access the resources on the OSS through the CDN accelerated domain name, the error AccessDenied will be displayed. You can access the OSS resources through the following methods.

• When you access OSS resources through web pages, you can access them through CDN accelerated domain name + file access path. For example: when the CDN accelerated domain name is mydomain.cn and needs to access the file 123.jpg in the root directory, the access address is http://mydomain.cn/123.jpg .
• When you access OSS resources through the client, you can configure the OSS Bucket domain name in the client as a CDN accelerated domain name, and then use the CDN to accelerate domain name access.

Five, access method two-complete the configuration based on the OSS console

1. On the OSS console, configure Alibaba Cloud CDN acceleration.

  1. Log in to the OSS management console .
  2. Click the Bucket list in the left navigation bar.

image.png

  1. In the bucket list, click the name of the target bucket.
  2. Click Transfer Management> Domain Name Management in the navigation bar of the storage space.
  3. On the Domain Name Management tab, click the unconfigured corresponding domain name that needs to be configured with Alibaba Cloud CDN, and the system will automatically jump to the CDN management console.

image.png

2. On the CDN console, add a domain name, the steps are the same as above.
3. On the CDN console, get the CNAME, the steps are the same as above.
4. On the Alibaba Cloud DNS console, configure CNAME, the steps are the same as above.
5. On the local PC, verify that the CNAME configuration takes effect. The steps are the same as above.
6. On the OSS console, turn on the CDN cache automatic refresh switch of the accelerated domain name, and the steps are the same as above.

Guess you like

Origin blog.csdn.net/qq_33857573/article/details/108531201
cdn