Cut OSS Storage Costs with Real‑Time Image Processing Using Function Compute
This guide explains how to store only original images in Alibaba Cloud OSS and use Object Process Access Point (OPAP) together with Function Compute to dynamically transform images on demand for different devices, thereby reducing storage expenses while supporting flexible processing like watermarking, resizing, and format conversion.
Solution Overview
Most customers store large volumes of unstructured media (images, video, audio) in Alibaba Cloud Object Storage Service (OSS). Different devices require different image formats and resolutions, which leads to many derivative files and high storage costs. OSS Object FC enables storing only the original image in OSS and generating the required version in real time based on request parameters, eliminating the need to keep all derivative files.
Typical Scenarios
Scenario 1: Only the original image is stored in OSS. The client includes processing parameters (e.g., format, size, watermark) in the request URL; the returned image is already transformed according to those parameters.
Scenario 2: A single format image is stored in OSS. Regardless of the format requested in the URL, the system returns the image in the requested format after on‑demand conversion.
Advantages
Only the original image needs to be retained, significantly reducing OSS storage costs.
Business logic such as watermarking, beautification, cropping, or frame extraction can be applied at request time without custom development on the OSS side, giving customers full control and strong extensibility.
Key Terminology
OPAP (Object Process Access Point): An extension of the standard Access Point (AP). A GetObject request to an OPAP triggers a Function Compute (FC) function; other request types fall back to the bound AP.
AP (Access Point): A dedicated OSS domain name with independent permission control, allowing fine‑grained access for different business units.
Product Components
VPC (Virtual Private Cloud): Isolated private network for deploying cloud resources such as ECS, SLB, RDS, etc.
Function Compute (FC): Event‑driven, fully managed serverless compute service. Users upload code or container images; the platform handles scaling, logging, monitoring, and alerts.
CDN (Content Delivery Network): Distributed edge servers cache origin resources to reduce latency and origin load.
OSS (Object Storage Service): Highly durable, low‑cost cloud storage with 99.9999999999% data durability and 99.995% availability.
CADT (Cloud Architect Design Tools): Self‑service tool that provides templates and drag‑and‑drop design for rapid deployment of cloud architectures.
Prerequisites
Alibaba Cloud account with real‑name verification completed.
Pay‑as‑you‑go resources purchased; account balance > ¥200 to cover hourly charges.
Git environment ready to clone the sample repository.
Domain name that has passed ICP filing.
Step‑by‑Step Implementation
Environment preparation
Clone sample code
git clone https://github.com/aliyun-samples/oss-object-fc-demo.gitConfigure OSS
Create an Access Point (AP).
Create an Object FC Access Point (OPAP) linked to the AP.
Grant required RAM permissions to the OPAP.
Upload sample images to the bucket.
Configure Function Compute
Log in to the FC console.
Deploy the image‑processing function code (the function parses URL parameters and applies the requested transformations).
Update the OSS SDK and pyOpenSSL dependencies in the function package.
Configure CDN
Add a CDN domain that points to the OPAP as the origin.
Configure CNAME resolution for the domain to the CDN endpoint.
Set cache‑behavior and header forwarding rules as needed.
Validate Scenarios
Test format conversion by requesting https://cdn.example.com/image.jpg?format=png.
Test real‑time resizing with parameters such as w=200&h=150.
Explore additional use cases (watermark, cropping, frame extraction).
Resource cleanup – release VPC, FC, CDN, and OSS resources with a single click after testing.
Full Request Flow
User requests an image via a CDN URL.
If the CDN cache misses, the request is forwarded to the OPAP.
The OPAP triggers the Function Compute function; the function extracts processing parameters from the URL and performs the image transformation.
The processed image is returned to the AP, which forwards it to OSS.
OSS serves the image back to the CDN, which delivers it to the client.
All configurations—CDN origin settings, OPAP creation, AP creation, and function code—are performed through the Alibaba Cloud console.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Native
We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
