You can use the CDN secondary origin server feature to periodically sync content from your primary origin to a secondary origin. When the primary origin becomes unavailable, CDN automatically routes origin fetches to the secondary origin to keep your service running.
Prerequisites
-
You have activated the Function Compute service. For more information, see Activate Service.
NoteIf Function Compute is not activated, CDN secondary origin server tasks cannot invoke the required functions after you create them.
-
You have activated Object Storage Service (OSS) and created a bucket. For more information, see Create a bucket in the console.
Billing
-
Function Compute service fees:
The CDN secondary origin server feature uses Function Compute and is billed on a pay-as-you-go basis. For a detailed breakdown of Function Compute charges, see Billing overview. The fees for Function Compute consist of the following two items:
Billable item
Billing rules
Internet data transfers fee
Internet data transfers fee = Tiered unit price × Data transfer usage
Tiered unit price: The first 200 GB of data transfers per month is free. This includes 20 GB for all regions (including the Chinese mainland) and 180 GB for regions outside the Chinese mainland. Data transfers that exceed 200 GB are billed at tiered rates. The rates vary by region. For more information, see Cloud Data Transfer (CDT) pricing for Internet data transfers.
Data transfer usage: You can view your Internet data transfers on the Resource Usage Details page in the Function Compute console.
Function Compute CU usage fee
CU usage fee = CU usage × CU unit price
CU usage = Usage of each resource × CU conversion factor
Usage of each resource: You can view the usage of each resource on the Resource Usage Details page in the Function Compute console.
CU conversion factor: See the CU conversion factor table.
CU unit price: See the Billable items and unit prices table.
-
OSS storage fees:
Currently, you can only use the public endpoints of OSS buckets as secondary origin addresses. When files from your primary origin are synced and stored in OSS, you incur storage fees based on the file type, size, and storage duration. For detailed pricing information, see Storage fees.
Create a CDN secondary origin task
-
Log on to the CDN console.
-
In the left-side navigation pane, click Application Center.
-
On the Application Center page, find the Secondary Origin Servers card and click Try Now.
-
On the Secondary Origin Servers page, click Create Task.
-
On the Create Scheduled Task page, configure the following parameters.
Parameter
Description
Task Name
The name of the CDN secondary origin server task.
Permission Management
When you use the CDN secondary origin server feature for the first time, you must authorize Function Compute.
On the authorization page, keep the default values for the following parameters:
-
Role name:
AliyunCDNServerlessDevsRole. -
Role description:
Serverless Devs Role for CDN Application. -
System policy:
AliyunFCFullAccessandAliyunOSSFullAccess.
Type
Domain name.
Domain Name
The domain name of the site to back up.
Secondary Origin Address
The public endpoint of an Alibaba Cloud OSS bucket to use as the secondary origin for storing backups.
Task Type
Recurring task.
Trigger Mode
Specifies how to trigger the CDN secondary origin server task.
-
At Specific Interval: Triggers the task at a specified time interval.
-
At Specific Time: Triggers the task at a specified time, date, or day of the week.
Resource Type
The type of resources to back up.
-
Configure the secondary origin address
Add the Secondary Origin Address specified in Create a CDN secondary origin server task to the Origin Information settings of your domain. For more information, see Configure an origin.
When you add the secondary origin address, configure the following parameters:
-
Origin Information: Select OSS Domain and enter the Secondary Origin Address from Create a CDN secondary origin server task.
-
Priority: Select Secondary.
Permissions for RAM users
A RAM user must have the required permissions to create CDN secondary origin server tasks.
Granting a RAM user the
AliyunFCFullAccessandAliyunOSSFullAccesssystem permissions by using a system policy gives the user permissions to manage all of Function Compute and Object Storage Service (OSS).-
Log on to the RAM console.
-
In the left-side navigation pane, choose Identities > Users.
-
Find the target RAM user and click Add Permissions in the Actions column.
-
In the Grant Permission panel, configure the authorization information.
-
For Authorization scope, select Account.
-
For Policies, set Policy type to System policy.
-
In the Policies search box, enter
AliyunFCFullAccessandAliyunOSSFullAccess, select them from the results, which adds them to the Selected policy list.
-
-
Click Confirm.
-
Click Disable.
-
-
Create a custom policy and grant the
ListRolespermission to the RAM user.-
In the left-side navigation pane of the RAM console, choose Permissions > Policies.
-
Click Create policy.
-
Click the JSON tab.
In the editor, enter the following custom policy document.
{ "Version": "1", "Statement": [ { "Effect": "Allow", "Action": [ "ram:CreateRole", "ram:AttachPolicyToRole", "ram:ListRoles" ], "Resource": "*" } ] } -
Click OK.
-
On the Create policy page, configure the Name and Remarks.
Parameter
Description
Name
Enter a descriptive name to help you identify the policy.
Remarks
Optional. Enter a description for the policy.
-
Click OK.
-
In the left-side navigation pane, choose Identities > Users.
-
Find the target RAM user and click Add Permissions in the Actions column.
-
In the Grant Permission panel, configure the authorization information.
Parameter
Description
Authorization scope
Select Account. This applies the permissions at the account level. You cannot select Resource Group.
Principal
This field is automatically populated with the RAM user that you selected.
Policy
Set Policy type to Custom Policies. In the search box, enter the name of the custom policy that you created, select it, and add it to the Selected policy list.
-
Click Confirm.
-
Click Disable.
-