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.Data source type
Source description
Parameters
URL
URL
-
url: The download address of the data. -
accessToken: An access token required to access private data.
HuggingFace or ModelScope
-
repoSource: The source of the model or dataset. Valid values:ModelScope/Model,ModelScope/DataSet,HuggingFace/Model, andHuggingFace/DataSet. -
repoId: The ID of the model or dataset. -
revision: The version. Default value:mainormaster. -
accessToken: An access token required to access private data.
NAS
NAS file system
-
server: The mount point of the Apsara File Storage for NAS (NAS) file system. -
path: The subdirectory to mount. For Extreme NAS file systems, the path must start with/share, such as/share/path. -
vers: The NFS protocol version. We recommend that you usev3. Extreme NAS file systems support onlyv3. -
options: The mount options. We recommend that you use the options suggested by the NAS service, such asnolock,tcp,noresvport.
OSS
Object Storage Service (OSS) bucket
-
bucket: The name of the OSS bucket. -
url: The endpoint of the OSS bucket. -
path: The subdirectory to mount. This is the directory relative to the root directory of the bucket. Default value:/. -
otherOpts: Custom parameters for mounting the OSS bucket. The format is-o *** -o ***. Example:-o max_stat_cache_size=0 -o allow_other. -
ramRole: The RAM role 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 Manage RAM role permissions.
When you create the role, set Alibaba Cloud Service to Normal Service Role, Elastic Compute Service to Normal Service Role, and Trusted Service to Elastic Compute Service. When you grant permissions, select the AliyunOSSFullAccess permission policy.
-
akId: The AccessKey ID for direct authorization. For more information, see Obtain an AccessKey pair. -
akSecret: The AccessKey secret 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.
When you pull data from the internet, if your business is deployed in Chinese mainland regions, we recommend that you create the data cache in the China (Hong Kong) region and then copy it to the required 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.