All Products
Search
Document Center

Function Compute (2.0):Overview

Last Updated:Mar 06, 2024

Alibaba Cloud Content Delivery Network (CDN) is seamlessly integrated with Function Compute. You can write a function to perform custom processing on CDN events. Then, you can configure a CDN event trigger to trigger the execution of the function when the CDN system receives an event that is of the specified type and meets the filtering criteria.

Background information

Alibaba Cloud CDN is a distributed network that is built on top of the bearer network and consists of edge server clusters distributed in different regions. You can replace the traditional web server-based data transmission mode by using Alibaba Cloud CDN to cache resources of the origin to edge servers distributed all over China. The caching allows you to obtain data from the nearest servers. In this way, user experience is improved and the loads on the origin are reduced. In Function Compute, you can configure a CDN event trigger to integrate the CDN service to perform custom processing on various CDN events. For example, you can set a function and a corresponding CDN event trigger to process resource refresh events in the www.taobao.com domain. When a resource refresh event occurs in the domain, the CDN event trigger automatically triggers the execution of the function.

Scenarios

A CDN event trigger can integrate the Function Compute service and the CDN service in the following scenarios:

  • When user data is preloaded and refreshed in the CDN system, CachedObjectsPushed and CachedObjectsRefreshed events occur, respectively. The CDN event trigger automatically triggers the execution of the specified function. In this way, you can learn about the preload and refresh statuses of resources in a timely manner before proceeding to the next step, avoiding constantly polling the list for the latest status.

  • When a log file is generated, a LogFileCreated event occurs. The CDN event trigger automatically triggers the execution of the specified function to process the log. In this way, you can dump or process logs in a timely manner without waiting for logs.

  • When a domain name for CDN is enabled or disabled, a CdnDomainStarted or CdnDomainStopped event occurs, respectively. The CDN event trigger automatically triggers the execution of the specified function to process data in a timely manner.

CDN events

When the CDN system detects a related event, the CDN system encodes the information about the event into a JSON string and passes the JSON string to the corresponding function for processing. The following table lists the events and versions that are currently supported by CDN event triggers.

Event

Version

Filtering parameter

Reference

CachedObjectsRefreshed

1.0.0

domain

RefreshObjectCaches

CachedObjectsPushed

1.0.0

domain

PushObjectCache

LogFileCreated

1.0.0

domain

DescribeCdnDomainLogs

CdnDomainStarted

1.0.0

domain

StartCdnDomain

CdnDomainStopped

1.0.0

domain

StopCdnDomain

CdnDomainAdded

1.0.0

domain

AddCdnDomain

CdnDomainDeleted

1.0.0

domain

DeleteCdnDomain