Select a function storage type

更新时间:
复制 MD 格式

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 typeBest forPersistentShared across invocationsMax size
NASLarge files shared across functions; workloads requiring a POSIX file system interfaceYesYesElastic
OSSHigh-volume unstructured data (images, audio, video, logs); event-driven pipelinesYesYesElastic
Temporary diskIntermediate computation files that do not need to survive beyond the function instanceNoNo512 MB or 10 GB
LayerShared dependency libraries, runtimes, and function extensions across deploymentsYesYes500 MB

Storage type comparison

AttributeNASOSSTemporary diskLayer
ScenariosLog and business file storageLog and business file storageTemporary files from business operationsPublishing and deployment of public dependency libraries, runtime environments, and function extensions
Maximum spaceElasticElastic512 MB or 10 GB500 MB
PersistencePersistentPersistentTemporaryPersistent
Shared between invocationsYesYesNoYes
Read/writeWritableWritableWritableRead-only
Storage typeFile systemObjectFile systemCode dependency archive
Event source integrationNoYesNoNo
Function access speedFasterFastFastestFast
BillingNAS billing overviewOSS billing overviewFree 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.

What's next