The cache disk of a file gateway stores data and metadata locally to deliver low-latency read/write access, then uploads data to Object Storage Service (OSS) asynchronously in the background.
How caching works
The cache disk is a cloud disk attached to your Cloud Storage Gateway (CSG) instance. It buffers data and metadata locally to accelerate file operations. The cache disk provides four capabilities:
Write caching: Data written through the mount target is held in the cache disk. After a file is closed, the gateway uploads cached data to OSS asynchronously. This mechanism supports both sequential and random writes. After the upload completes, the gateway reclaims the cache space based on a predefined eviction policy.
Read caching: Recently read data is stored in the cache disk to reduce latency for repeated access. For large files, a pre-read mechanism loads data into the cache disk in advance to increase read bandwidth.
Metadata caching: The cache disk stores metadata such as the directory structure to accelerate file system operations like
lsandstat. The gateway supports three metadata synchronization modes — express sync, scheduled remote sync, and one-time remote sync — to match different data consistency requirements.Automatic eviction: The gateway evicts data that has not been accessed for an extended period. Only data is evicted — metadata such as filenames, directory structure, and permissions is retained. This keeps cache disk usage at a healthy level, typically around 60%.
The cache disk allocates space proportionally: 80% for the data cache and 20% for the metadata cache.
Cache sizing guidelines
Follow these steps to size your cache disk correctly.
-
Select a cache disk type.
Match the disk type to your bandwidth and IOPS requirements. The cache disk performance must align with your gateway specification: - Basic and Standard gateways: Use an ESSD PL1 cache disk. - Enhanced and Compute-optimized gateways: Use an ESSD PL2 cache disk.
-
Select a cache disk capacity.
Size the cache disk to cover both data cache and metadata cache requirements.
Data cache capacity: To prevent write failures or performance degradation, the available cache space for data must satisfy:
Available cache space > Concurrency x Maximum file size. For better performance, reserve an additional 30% of free space beyond this minimum.-
Metadata cache capacity: The metadata cache stores file system structural information, including the following:
Directory hierarchy: The full directory tree structure.
File attributes: Properties such as size, creation time, and modification time.
Stub files: When the gateway evicts cached data for a file, it retains the file record in the metadata. This ensures a consistent directory view. When a user accesses an evicted file, the gateway automatically reloads the data from OSS.
As a general guideline, a 100 GB cache disk can manage the metadata for approximately 10 million files.
Monitor cache usage and scale out when needed. When the data cache or metadata cache runs out of space, the system triggers throttling alerts and insufficient metadata space alerts. Scale out the cache disk promptly after receiving an alert to avoid business interruptions.