Serverless event-driven architecture in practice
This solution uses Alibaba Cloud Function Compute to build a serverless, event-driven system. Function Compute eliminates infrastructure management and cuts costs with its pay-as-you-go model. It uses an event-driven approach to decouple services and enable asynchronous processing. It delivers high scalability and auto scaling, supports multiple programming languages and a wide range of triggers, and integrates seamlessly with other cloud services. This improves developer productivity and reduces operational overhead.
Who is this for?
Social media applications that require flexible, asynchronous processing of media files.
Large-scale enterprise collaboration systems that automate complex workflows.
High-concurrency, cross-region event-driven IoT platforms.
Solution advantages
Why choose Function Compute?
As a core service in modern cloud computing, Function Compute is an efficient and flexible solution for enterprises. When building event-driven applications, Function Compute easily handles complex business logic and variable workloads. It lets developers focus on core business logic without managing or scaling the underlying infrastructure. Function Compute significantly reduces operational costs with a pay-as-you-go model that prevents resource idling. It delivers excellent scalability, automatically adjusting resources based on request volume to handle traffic spikes. It also supports multiple programming languages and a rich set of triggers, simplifying integration with other cloud services and accelerating application development and deployment. Function Compute is the ideal choice for businesses that need to respond quickly to market changes and optimize resource utilization for building modern, high-efficiency applications.

Decouple core business logic
Decouple file processing tasks from your core application to reduce resource consumption, enhance security, and improve maintainability.

Pay-as-you-go pricing
The pay-as-you-go model bills you only for the compute resources you use, ensuring high resource utilization.

Auto scaling
Automatically scales compute resources to match request volume, seamlessly handling traffic spikes without manual intervention.
Processing files within the application
Processing files with Function Compute
Low stability
High compute resource consumption can lead to CPU, memory, and I/O contention, affecting system stability.
Stability
High availability
Decoupling core business logic from file processing tasks allows the cloud provider to ensure high availability for your functions.
Difficult to scale
Dynamic scaling is difficult. You must pre-provision significant compute resources to handle peak traffic.
Scalability
Auto scaling
Provides auto scaling to handle traffic bursts, backed by robust resource delivery capabilities.
High cost
Pre-provisioning resources for peak traffic results in low utilization and wasted resources.
Cost
Pay-as-you-go
You are billed for compute resources only when files are processed. This pay-as-you-go model saves money.
Architecture and deployment
Process media files using Function Compute
2807391
This solution uses ECS and ApsaraDB RDS for MySQL to host a web service and stores user files in OSS. The architecture works as follows: A user uploads a file directly to OSS using a server-side signed URL, which offloads network traffic from the web server. When the upload is complete, OSS automatically generates an event that triggers a Function Compute function to process the file. In this example, the function converts a PowerPoint (PPT) file to a PDF and adds a watermark. Once the processing is finished, another event triggers a message in ApsaraMQ for MNS, which then notifies the web application that the processed file is ready.
30 minutes
CNY 30(This is an estimate based on the recommended specifications for ECS and ApsaraDB RDS for MySQL, assuming traffic is under 10 GB and usage does not exceed 24 hours. Actual costs may vary depending on the specifications and versions you select. Refer to the console for final pricing.)

Function ComputeOSSECSApsaraDB RDS for MySQLApsaraMQ for MNS
Application scenarios
Common application scenarios

Image processing
E-commerce and social media websites often process large volumes of images. Common tasks include resizing images for different screen resolutions, generating thumbnails, and adding watermarks to prevent unauthorized use.

Video processing
Video-on-demand and live streaming websites handle many video files. To ensure a high-quality viewing experience, they often need to perform tasks like transcoding, resolution adjustment, and generating first-frame thumbnails.

Real-time advertising (RTA)
Real-Time Advertising (RTA) systems process and analyze user data in real time to complete ad bidding and delivery within milliseconds.
Free trial
Alibaba Cloud provides free trials for cloud products
10000012572
942060
10000011871
10000009092