A data cache pulls the data for your applications in advance, allowing you to mount it directly when creating an Elastic Container Instance (ECI).
Create a data cache
You can create a data cache in one of the following ways:
-
OpenAPI: Call the CreateDataCache operation to create a data cache. For more information, see CreateDataCache.
-
Console: In the Elastic Container Instance console, go to the Data Cache page and click Create Data Cache. Configure the parameters as required and click OK.
Parameters
When you create a data cache, you must configure the following parameters:
-
Basic properties
API
Console
Description
RegionId
Region
The region where the data cache is located.
Bucket
Cache bucket
The bucket where the data is stored. The default value is
default. You can specify a custom bucket to group services and prevent path conflicts.The
eci-systembucket is reserved for ECI and cannot be used.Path
Cache directory
The storage path for the data.
Name
Cache name
The name of the data cache.
Size
Cache size
The size of the data cache. Unit: GiB. The default value is 20 GiB. We recommend that you estimate the required size based on your actual data volume.
RetentionDays
Retention period (days)
The number of days to retain the data cache. The cache is deleted after this period expires. By default, a data cache is retained indefinitely.
-
Data source
API
Console
Description
DataSource.Type
Type
The type of the data source.
DataSource.Options
Parameters
The configuration parameters for the data source, specified as a JSON object. Required parameters vary depending on the data source type.
The following table describes the data source types and their parameters.
ImportantWhen creating a data cache in the OpenAPI Portal, you must prefix each parameter name in
DataSource.Optionswith its character length. For example, you must writeurlas#3#url,repoIdas#6#repoId, andrepoSourceas#10#repoSource. This is not required when using an SDK.Type
Description
Parameter
URL
URL
-
url: The URL from which to download the data. -
accessToken: Configure this parameter to authenticate when you pull private data.
HuggingFace or ModelScope
-
repoSource: The source repository. Valid values areModelScope/Model,ModelScope/DataSet,HuggingFace/Model, andHuggingFace/DataSet. Specifies whether to pull a model or a dataset from ModelScope or HuggingFace. -
repoId: The ID of the model or dataset. -
revision: The version. The default value ismainormaster. -
accessToken: Configure this parameter to authenticate when you pull private data.
NAS
NAS file system
-
server: The mount target of the NAS file system. -
path: The subdirectory to mount. For Extreme NAS file systems, the path must start with/share, for example,/share/path. -
vers: The NFS protocol version for mounting the NAS file system. We recommend v3. Extreme NAS file systems support only v3. -
options: The mount options. We recommend using the options suggested by the File Storage NAS service, such asnolock,tcp,noresvport.
OSS
OSS bucket
-
bucket: The name of the OSS bucket. -
url: The OSS endpoint. -
path: The subdirectory to mount relative to the bucket root. The default value is/. -
otherOpts: Custom parameters for mounting OSS. The format is-o *** -o ***, for example,-o max_stat_cache_size=0 -o allow_other. -
ramRole: The RAM role to use for authorization.NoteYou must create a RAM role and grant permissions to it. For more information, see Create a RAM role for a trusted Alibaba Cloud service and Grant permissions to a RAM role.
When you create the role, set the Trusted Entity Type to Alibaba Cloud Service, the Role Type to Normal Service Role, and the Trusted Service to Elastic Compute Service. When you grant permissions to the role, select the AliyunOSSFullAccess policy.
-
akId: The AccessKey ID to use for direct authorization. For more information, see Obtain an AccessKey pair. -
akSecret: The AccessKey Secret to use for direct authorization. For more information, see Obtain an AccessKey pair.
SNAPSHOT
snapshot
snapshotId: The ID of the snapshot. -
-
Network parameters
If the specified vSwitch is not configured with an SNAT gateway, associate an Elastic IP address (EIP) to pull data from the internet.
API
Console
Description
EipInstanceId
Use existing
Associates an existing EIP.
Parameters included in EipCreateParam
Auto create
Automatically creates and associates an EIP.
-
Other parameters
In addition to the preceding parameters, you must also specify a Virtual Private Cloud (VPC), a vSwitch, and a security group. The system uses these to create temporary resources during the data cache creation process.
Configuration examples
The following OpenAPI examples show how to configure parameters to create data caches of different types.
URL
-
Pull data from a URL
{ "RegionId": "cn-beijing", "SecurityGroupId": "sg-2ze63v3jtm8e6syi****", "VSwitchId": "vsw-2ze94pjtfuj9vaymf****", "Bucket": "test", "Path": "/demo/url", "Name": "test-url-1", "DataSource": { "Type": "URL", "Options": { "#10#url": "https://www.example.com" } }, "RetentionDays": 1 } -
Pull a model from HuggingFace
{ "RegionId": "cn-beijing", "SecurityGroupId": "sg-2ze63v3jtm8e6syi****", "VSwitchId": "vsw-2ze94pjtfuj9vaymf****", "Bucket": "test", "Path": "/demo/url", "Name": "test-url-2", "DataSource": { "Type": "URL", "Options": { "#10#repoSource": "HuggingFace/Model", "#6#repoId": "stabilityai/stable-diffusion-2-1" } }, "RetentionDays": 1 }
NAS
{
"RegionId": "cn-beijing",
"SecurityGroupId": "sg-2ze63v3jtm8e6syi****",
"VSwitchId": "vsw-2ze94pjtfuj9vaymf****",
"Bucket": "test",
"Path": "/demo/nas",
"Name": "test-nas",
"DataSource": {
"Type": "NAS",
"Options": {
"#6#server": "126c24****-tw***.cn-beijing.nas.aliyuncs.com",
"#4#path": "/",
"#4#vers": "3",
"#7#options": "nolock,tcp,noresvport"
}
},
"RetentionDays": 1
}
OSS
{
"RegionId": "cn-beijing",
"SecurityGroupId": "sg-2ze63v3jtm8e6syi****",
"VSwitchId": "vsw-2ze94pjtfuj9vaymf****",
"Bucket": "test",
"Path": "/demo/oss",
"Name": "test-oss",
"DataSource": {
"Type": "OSS",
"Options": {
"#6#bucket": "test-***",
"#3#url": "oss-cn-beijing-internal.aliyuncs.com",
"#4#path": "/test",
"#9#otherOpts": "-o max_stat_cache_size=0 -o allow_other",
"#7#ramRole": "<your RAM Role Name>"
}
},
"RetentionDays": 1,
"SourceIp": "2401:b180:1000:3:a4ba:83d6:a4ba:83d6"
}
SNAPSHOT
{
"RegionId": "cn-beijing",
"SecurityGroupId": "sg-2ze63v3jtm8e6syi****",
"VSwitchId": "vsw-2ze94pjtfuj9vaymf****",
"Bucket": "test",
"Path": "/demo/snapshot",
"Name": "test-snapshot",
"DataSource": {
"Type": "SNAPSHOT",
"Options": {
"#10#snapshotId": "s-2zehb6jegdehec19****"
}
},
"RetentionDays": 1,
"Size": 40
}
Manage data caches
Query data caches
After you create a data cache, you can query its information, such as its status, the bucket to which it belongs, and its storage path within the bucket. A data cache is ready for use when its status is Available.
You can query a data cache in one of the following ways:
-
OpenAPI: Call the DescribeDataCaches operation to query information about data caches.
-
Console: On the Data Cache page, you can view a list of all data caches in the current region. Click the ID of a data cache to view its details.
Update data caches
You can update the bucket, data source, retention period, and size of a data cache if its state is Available or UpdateFailed.
You can update a data cache in the following way:
-
OpenAPI: Call the UpdateDataCache operation to update a data cache.
-
Console: This feature is not supported.
Copy data caches
Data caches are region-specific. If your ECI instance is in a different region than the data cache, you must copy the data cache from the source region to the destination region.
You can copy a data cache in one of the following ways:
-
OpenAPI: Call the CopyDataCache operation to copy a data cache.
-
Console: On the Data Cache page, find the target data cache and click Copy in the Actions column.
Delete data caches
Each data cache corresponds to a snapshot. You are charged for snapshot storage fees to retain a data cache. If you no longer need a data cache that does not have a set retention period, we recommend that you promptly delete it to avoid ongoing storage fees.
You can delete a data cache in one of the following ways:
-
OpenAPI: Call the DeleteDataCache operation to delete a data cache.
-
Console: On the Data Cache page, find the target data cache and click Delete in the Actions column.