Function Compute supports four storage types: Apsara File Storage NAS (NAS), Object Storage Service (OSS), temporary disk, and layers. Choosing the wrong type can introduce data loss, unnecessary cost, or performance bottlenecks. This page compares the options so you can match each type to your workload.
Quick selection guide
| Storage type | Best for | Persistent | Shared across invocations | Max size |
|---|---|---|---|---|
| NAS | Large files shared across functions; workloads requiring a POSIX file system interface | Yes | Yes | Elastic |
| OSS | High-volume unstructured data (images, audio, video, logs); event-driven pipelines | Yes | Yes | Elastic |
| Temporary disk | Intermediate computation files that do not need to survive beyond the function instance | No | No | 512 MB or 10 GB |
| Layer | Shared dependency libraries, runtimes, and function extensions across deployments | Yes | Yes | 500 MB |
Storage type comparison
| Attribute | NAS | OSS | Temporary disk | Layer |
|---|---|---|---|---|
| Scenarios | Log and business file storage | Log and business file storage | Temporary files from business operations | Publishing and deployment of public dependency libraries, runtime environments, and function extensions |
| Maximum space | Elastic | Elastic | 512 MB or 10 GB | 500 MB |
| Persistence | Persistent | Persistent | Temporary | Persistent |
| Shared between invocations | Yes | Yes | No | Yes |
| Read/write | Writable | Writable | Writable | Read-only |
| Storage type | File system | Object | File system | Code dependency archive |
| Event source integration | No | Yes | No | No |
| Function access speed | Faster | Fast | Fastest | Fast |
| Billing | NAS billing overview | OSS billing overview | Free for disk space up to 10 GB. See Billing overview. | Free |
Apsara File Storage NAS
NAS is a distributed file storage system that provides secure, high-performance, and highly reliable file storage for services such as ECS, HPC, Docker, and BatchCompute.
After you configure NAS for a function—specifying the NAS region, mount target, and group—the function accesses the NAS file system as if it were a local file system.
Use cases:
Shared file access: Multiple functions using the same NAS file system can read and write the same files without copying data between them.
Large temporary files: Store temporary files whose size exceeds the local disk limit of a function instance.
For configuration steps, see Configure a NAS file system.
Object Storage Service (OSS)
OSS is a secure, cost-effective, and highly reliable cloud storage service for large amounts of unstructured data—images, audio, video, and logs.
Function Compute integrates with OSS in two ways:
Mount as a local file system: Configure an OSS mount for a function so it reads and writes OSS objects using standard file system calls. See Configure OSS object storage.
OSS triggers: Write functions that respond to OSS events. When OSS detects an event of a specified type, it triggers the corresponding function. This pattern suits real-time data processing pipelines—your function handles the logic while the system manages high-volume, parallel execution. See OSS trigger overview.
Temporary disk
Function Compute provides two temporary disk sizes: 512 MB and 10 GB. All directories on the temporary disk are writable and share the total disk space.
The temporary disk is tied to the lifecycle of the function's container instance. As long as invocations arrive continuously, the container—and its disk data—persists. If no invocations occur for an extended period, Function Compute reclaims the container and deletes the disk data.
Note: Do not use temporary disk for data that must survive across invocations or container restarts. Use NAS or OSS instead.
Layers
Layers let you publish and deploy shared resources—dependency libraries, runtime environments, and function extensions—independently of your function code. Attach a layer to one or more functions to share the same resources across deployments.
Reasons to use layers:
Reduce code package size: Extract dependency libraries from your deployment package into a layer. This speeds up deployments and reduces the size of your code package when you deploy or update a function.
Separate dependencies from function logic: Update your libraries independently of your function code, and vice versa.
Share dependencies across functions: Create a layer once and attach it to any function in your account.
Use official public layers: Function Compute provides official public layers for common runtimes and tools, so you do not need to package them yourself.
For operations and limits, see Create a custom layer and Layer limits.