You can configure lifecycle rules for a bucket based on the last access time of the objects in the bucket. After you configure a lifecycle rule for a bucket, Object Storage Service (OSS) monitors the access patterns of the objects in the bucket, identifies cold data, and converts the storage class of cold data. This way, cold data and hot data are stored by using different storage classes, and storage costs are reduced.
Scenarios
Multimedia
After you store the videos and images of your website in an OSS bucket, the data may become infrequently accessed over time. For data that becomes infrequently accessed, you may need to convert the storage class to Infrequent Access (IA). For data that was uploaded for a long time but is still frequently accessed, you must retain the Standard storage class. You can configure a lifecycle rule for the bucket based on the last access time of the objects in the bucket. This way, cold data and hot data are stored by using different storage classes, and storage costs are reduced.
Albums or network disks
You can configure a lifecycle rule for a bucket that is used to store albums or is used as a network disk based on the last access time of the objects in the bucket. After the lifecycle rule is triggered, the storage class of cold data is automatically converted to IA. You can access the data in real time.
Life science
A large amount of data is generated in gene sequencing. Users need to determine whether the data is frequently accessed based on the last access time instead of the last modified time of the data. In the past, users must use methods such as log analysis to identify and manage cold and hot data. At present, you can configure a lifecycle rule based on the last access time of the objects in the bucket. This way, OSS automatically identifies cold and hot data based on the last access time of the objects and stores the objects by using different storage classes. You can also specify policies based on the last access time and the last modified time in the same lifecycle rule to manage data in a more flexible manner.
Limits
Data deletion
You cannot delete data by using the lifecycle rules that are configured based on the last access time.
Match conditions
Currently, lifecycle rules support only matching based on prefixes and tags. Wildcard matching, suffix matching, and regular expression matching are not supported.
Part lifecycle
You cannot configure two or more lifecycle rules that contain a part lifecycle policy for objects whose names contain overlapping prefixes. Examples:
- Example 1
If you configure a lifecycle rule that contains a part lifecycle policy for a bucket, you cannot configure another lifecycle rule that contains a part lifecycle policy for objects whose names contain any prefix in the bucket.
- Example 2
If you configure a lifecycle rule that contains a part lifecycle policy for objects whose names contain the dir1 prefix in a bucket, you cannot configure another lifecycle rule that contains a part lifecycle policy for objects whose names contain overlapping prefixes, such as dir1/dir2.
Usage notes
Number of lifecycle rules
You can configure up to 100 lifecycle rules in the OSS console. You can also specify policies based on the last access time and last modified time in the same lifecycle rule. If you want to configure more than 100 lifecycle rules, use OSS SDKs or ossutil.
Fees
Object monitoring and management fees
After you enable access tracking for a bucket, object monitoring and management fees are generated. However, you are not charged the fees.
Storage fees for IA objects that are stored for less than the minimum storage duration
IA objects have a minimum storage duration of 30 days. If the IA objects are stored for less than 30 days, you are charged storage fees for 30 days. The following examples show how IA objects are billed when you configure lifecycle rules based on the last access time of the objects:
Example 1: OSS converts a Standard object to an IA object 10 days after the object is created and converts the IA object to a Standard object after 5 days based on the configured lifecycle rule. In this case, you are charged storage fees for the remaining 15 days.
Example 2: OSS converts a Standard object to an IA object 10 days after the object is created and deletes the IA object after 15 days based on the configured lifecycle rule. In this case, you are charged storage fees for the remaining 5 days.
For more information, see Storage fees.
Retrieval fees for IA objects
When you access IA objects, you are charged data retrieval fees based on the size of the retrieved IA objects. For more information, see Data processing fees.
API operation calling fees
When you convert storage classes of objects by using lifecycle rules, you are charged API operation calling fees. For more information, see API operation calling fees.
Overwriting semantics
The PutBucketLifecycle operation overwrites the existing configurations of a lifecycle rule that is configured for a bucket. For example, if a lifecycle rule named Rule1 is configured for a bucket and you want to configure a lifecycle rule named Rule2 for the bucket based on Rule1, perform the following operations:
- Call the GetBucketLifecycle operation to query Rule1.
- Configure Rule2 for the bucket based on Rule1.
- Call the PutBucketLifecycle operation to update the lifecycle rule configurations of the bucket. In this case, Rule1 and Rule2 are configured for the bucket.
Effective time
After you configure a lifecycle rule, OSS loads the rule within 24 hours. After the lifecycle rule is loaded, OSS runs the rule every day at 08:00:00 (UTC+8).
Completion time
For a lifecycle rule that does not contain tags, you can perform up to 1 billion lifecycle-related operations within 24 hours, such as object storage class conversion and the operation that can be performed on the expired parts. If you want to perform more than 1 billion lifecycle-related operations, the time period that is required to complete the operations may exceed 24 hours.
For a lifecycle rule that contains tags, you can perform up to 500 million lifecycle-related operations within 24 hours, such as object storage class conversion and the operation that can be performed on the expired parts. If you want to perform more than 500 million lifecycle-related operations, the time period that is required to complete the operations may exceed 24 hours.
Policies for updating the last access time
After you turn on Enable access tracking for a bucket on the Lifecycle page, the last access time of all objects in the bucket is set to the time when access tracking is enabled. If multiple GetObject requests are sent to access the same object within 24 hours, the last access time of the object is set to the time when the object is accessed by the first GetObject request. If other requests, such as PutObject and CopyObject requests, are sent to access an object, the last access time of the object is updated based on the request time.
For more information about the operations that can update the last access time of an object, see Which operations update the last access time of an object?
Supported storage classes
You can specify policies in a lifecycle rule that is configured based on the last access time of objects to convert the storage class of the objects from Standard to IA. You can also specify whether to convert the storage class of the objects from IA to Standard when the objects are accessed.
You can specify policies in a lifecycle rule that is configured based on the last access time of objects to convert the storage class of the objects from Standard or IA to Archive or Cold Archive. You can also specify policies in the lifecycle rule to convert the storage class of the objects from Archive to Cold Archive. If you want to convert the storage class of objects from Standard or IA to Archive or Cold Archive, submit a ticket to apply for the required permissions. After the application is approved, you must specify the storage class to which you want to convert the objects.
ImportantAfter the application is approved, if you configure a lifecycle rule based on the last access time of objects for a bucket to convert the storage class of the objects in the bucket from Standard or IA to Archive or Cold Archive, the last access time of the Archive or Cold Archive objects in the bucket is the time when access tracking is enabled for the bucket.
Configure a lifecycle rule for a bucket for which OSS-HDFS is enabled
To configure or modify a lifecycle rule to match all objects in a bucket for which OSS-HDFS is enabled, use the NOT element to exclude the objects that are stored in the .dlsdata/
directory. This prevents storage class conversion operations that are triggered by the lifecycle rule from affecting data read and write operations on OSS-HDFS data.
