Use Function Compute to process website files

更新时间:
复制 MD 格式

Function Compute automates file operations—compression, decompression, packaging, image processing, and web crawling—triggered by OSS events or HTTP requests, without managing servers.

Use cases

An image website that provides image tagging services typically needs several file-processing pipelines running in the background. Function Compute handles each as an event-driven workflow:

  • Automatic package update — When a specific image is updated and uploaded to an OSS directory, Function Compute compresses the relevant objects and distributes the package to workgroups. Each workgroup verifies file integrity using the MD5 checksum of the downloaded package.

  • Automatic decompression — When packaged images for public display are uploaded to OSS, Function Compute decompresses the packages so the images can be referenced directly by front-end pages. It also extracts image metadata for downstream use.

  • Automatic web crawling — Function Compute crawls specific images from image groups on the website and adds them to the asset libraries.

  • Automatic packaging — When a user downloads images from an image group, Function Compute automatically packages and distributes the selected images, even as image groups are updated periodically.

  • Screenshot archiving, image resolution standardization, and watermarking — Function Compute captures screenshots of web pages on a schedule and archives them. It also applies consistent resolutions and adds watermarks to images.

How it works

The following figure shows the architecture of the solution.

image

The solution uses three Alibaba Cloud services:

ServiceRole
Object Storage Service (OSS)Stores source images and triggers functions when objects are uploaded or updated.
Function ComputeRuns the processing logic. OSS triggers and HTTP triggers invoke the corresponding function based on the incoming event.
Simple Log ServiceWrites all function execution logs to the corresponding project for debugging and querying.

When you upload an object to OSS or send an HTTP request, the corresponding trigger fires and passes the event parameters to Function Compute. The function processes the images based on those parameters.

Benefits

BenefitDescription
Elastic scalingFunction Compute scales automatically with the volume of events and requests, matching file-processing capacity to demand without manual intervention.
Pay-per-useCharges apply only to used resources, with metering granularity accurate to milliseconds.
Isolated executionFiles are processed on different ECS instances to ensure data security.

Implementation details

For more information, see Serverless Best Practices for Website File Processing.