CDN Dynamic Acceleration Uploading Data to BOS
Overview
This article primarily explains how to use the Dynamic Route Content Delivery Network (DRCDN) to enhance the transmission speed and stability of the client’s data upload process to BOS.
Requirement scenarios
To cater to users’ acceleration needs when uploading data to BOS, this feature fully leverages the advanced architecture of Baidu AI Cloud’s DRCDN. By using methods such as upload link optimization, private protocols, real-time adaptation, and intelligent path switching, it significantly reduces data uplink transmission time and speeds up file uploads to BOS.
The Dynamic Route Content Delivery Network (DRCDN) of BOS can meet customers’ acceleration needs in various data uplink transmission application scenarios such as audio, video, and pictures, such as:
- Ordinary file upload acceleration scenarios
- Small file upload scenarios
- Long-distance file upload scenarios
- File upload scenarios in weak network environments such as network congestion
- Cross-network and cross-operator file upload scenarios
Advantages
Using Dynamic Route Content Delivery Network (DRCDN) to upload data to BOS has the following advantages:
- Through Baidu’s high-quality DRCDN nodes around the world, it solves problems for users such as slow upload speed to BOS, data packet loss, and unstable services caused by factors like cross-operator, transnational, and unstable networks, providing users with a fast, reliable, and smooth data upload experience;
- Baidu's self-developed comprehensive optimization acceleration solution specifically for the entire process of file uplink transmission. Through core technologies such as link optimization, protocol layer optimization, routing optimization, transmission optimization, and intelligent path switching, with multi-line access to central nodes, real-time detection and intelligent selection of back-to-origin links, the optimal path for transmission is obtained to significantly improve the upload acceleration effect;
- Dynamic Route Content Delivery Network (DRCDN) provides dynamic HTTPS request acceleration for fast transmission of encrypted data while also offering protection against DDoS and CC attacks, ensuring both availability and security during the data upload process.
Practice steps
For example, when users upload binary files like videos or pictures, using Dynamic Route Content Delivery Network (DRCDN) to upload data to BOS can streamline the process, enhancing upload speed and user experience with minimal additional cost. The specific solutions and steps are as follows:
Step 1: Enable DRCDN uplink acceleration
- Log in to the console, navigate to the bucket release management page for which uplink acceleration needs to be enabled, and activate the official domain name acceleration for this bucket. Select Dynamic Route Content Delivery Network (DRCDN) as the acceleration type. Once activated, charges for using DRCDN will apply.
- For detailed enabling methods, please refer to Console Operation Guide - Data Publishing - DRCDN Uplink Acceleration.
Step 2: Use DRCDN to accelerate data upload
BOS provides various file upload solutions such as console upload, upload using API or SDK, and upload using BOS CLI. You can choose [Upload using API or SDK](BOS/Developer Guide/Object Basic Operations/Uploading Data/Simple upload.md).
Upload files via API acceleration
When uploading data to BOS through the [PutObject API](BOS/API Reference/Object-Related Interface/Basic Operations/PutObject.md) of BOS API, you only need to replace the HOST of the API request with the DRCDN acceleration domain name (that is, your custom acceleration domain name or the official CDN acceleration domain name + '/' + 'file name') to achieve upload acceleration through DRCDN. For example: Original upload request:
1PUT /<ObjectName> HTTP/1.1
2Host: <BucketName>.bj.bcebos.com
3Date: <Date>
4Authorization: <AuthorizationString>
5Content-Type: text/plain
6Content-Length: <Content_Length>
CDN-accelerated upload request:
1PUT /<ObjectName> HTTP/1.1
2Host: <BucketName>.cdn.bcebos.com
3Date: <Date>
4Authorization: <AuthorizationString>
5Content-Type: text/plain
6Content-Length: <Content_Length>
Upload files via SDK acceleration
The configuration and usage of DRCDN-accelerated uploads vary across SDKs in different programming languages. This example demonstrates uploading a file using the Go SDK. For instructions on other languages, please refer to the respective SDK documents.
- The SDK configures the acceleration domain name for DRCDN accelerated upload as the ENDPOINT. For example,
cdn-test.cdn.bcebos.comis the CDN acceleration domain name corresponding to the bucket named cdn-test obtained after enabling the Dynamic Route Content Delivery Network (DRCDN) in the console. The code is as follows:
1AK, SK := "xxx", "yyy"
2ENDPOINT := "cdn-test.cdn.bcebos.com"
3bosClient, _ := bos.NewClient(AK, SK, ENDPOINT)
- Configure and enable the DRCDN accelerated upload switch. It should be noted that the CnameEnabled configuration item indicates whether to use a custom domain name to upload files to BOS. If your ENDPOINT is the official acceleration domain name with the suffix
.cdn.bcebos.com, this switch does not need to be configured; if your ENDPOINT is a custom acceleration domain name, you must set CnameEnabled to true for it to take effect.
1bosClient.Config.CnameEnabled = true
- Use the configured bosClient to upload files and experience CDN acceleration. After the upload is complete, verify whether the file has been successfully uploaded.
1bosClient.PutObjectFromFile(bucketName, objectName, filePath, nil)
Configure retry backup domain name
On the basis of supporting the configuration of DRCDN domain name to accelerate file upload to BOS, considering the stability of the upload process, the SDK further supports the mechanism of retrying the backup domain name when the upload via the primary domain name fails. The usage method is as follows:
1// If uploading files using ENDPOINT fails, the SDK will automatically retry the BackupEndpoint domain name
2bosClient.Config.BackupEndpoint = "cdn-test.bj.bcebos.com"
Related products
Content Delivery Network (CDN), Dynamic Route Content Delivery Network (DRCDN)
